C. Roads in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own l…
D. Roads not only in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Berland Government decided to improve relations with neighboring countries. First of all, it was decided to bui…
Codeforces Beta Round #25 (Div. 2 Only) http://codeforces.com/contest/25 A #include<bits/stdc++.h> using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define sqr(x) ((x)*(x)) #define maxn 500005 typedef long long…
题目链接:http://www.codeforces.com/problemset/problem/25/A题意:在n个书中找到唯一一个奇偶性和其他n-1个数不同的数.C++代码: #include <iostream> using namespace std; ; , y = -; int main() { cin >> n; ; i <= n; i ++) { cin >> a; == ) x = (x == -) ? i : -; else y = (y =…
IQ test time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from t…
A. IQ test time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the givenn numbers differs from…
E. Test time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Sometimes it is hard to prepare tests for programming problems. Now Bob is preparing tests to new problem about strings — input data…
题目链接:http://codeforces.com/problemset/problem/118/E 思路:首先要判断图是否是边双连通,这个Tarjan算法可以判断,若low[v] > dfn[u],则说明边(u,v)是桥,从而这个图不是边双连通,然后发现在判断的时候已经访问了所有的顶点,顺便加入就可以了. #include <iostream> #include <cstdio> #include <cstring> #include <algorith…
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0,那么这个点就是水龙头点. 如果这个点的出度为0,那么这个点就是储存点. 现在让你把所有水龙头到储存点的路径都输出出来,且输出这条路径的边权最小值 题解 显然是个仙人掌图,所以直接XJB暴力就好了 代码 #include<bits/stdc++.h> using namespace std; co…
Codeforces Beta Round #49 (Div. 2) http://codeforces.com/contest/53 A #include<bits/stdc++.h> using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define sqr(x) ((x)*(x)) #define pb push_back #define eb emplace_bac…