Submission #373239


Source Code Expand

#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<utility>
#include<complex>

using namespace std;

#define reE(i,a,b) for(auto (i)=(a);(i)<=(b);(i)++)
#define rE(i,b) reE(i,0,b)
#define reT(i,a,b) for(auto (i)=(a);(i)<(b);(i)++)
#define rT(i,b) reT(i,0,b)
#define rep(i,a,b) reE(i,a,b);
#define rev(i,a,b) for(auto (i)=(b)-1;(i)>=(a);(i)--)
#define fe(i,b) for (auto &(x):b);
#define itr(i,b) for(auto (i)=(b).begin();(i)!=(b).end();++(i))
#define rti(i,b) for(auto (i)=(b).rbegin();(i)!=(b).rend();++(i))
#define LL long long
#define all(b) (b).begin(),(b).end()

#define input_init stringstream ss; string strtoken, token; istringstream is
#define input_line  getline(cin, strtoken);is.str(strtoken);is.clear(istringstream::goodbit)
#define input_token(num) ss.str(""); ss.clear(stringstream::goodbit); getline(is, token, ','); ss << token; ss >> num

#define dir(xx,yy,x,y,i) (xx)=(x)+dir[(i)],(yy)=(y)+dir[(i)+1]

typedef complex<double> P;
typedef vector<P> Poly;

const LL INF = 1 << 25;
const double eps = 1e-8;
const int dir[] = { 0, 1, 0, -1, 0 };
vector<list<int>> adj;
vector<int> color;
int n, a, b;
void bfs(){
	queue < pair<int, int>> q;
	q.push(make_pair(-1, 0));
	color[0] = 0;
	while (q.empty() == false){
		int now = q.front().second;
		int from = q.front().first;
		q.pop();
		for (auto &to : adj[now]){
			if (color[to] == -1){
				color[to] = color[now] + 1;
				q.push(make_pair(now, to));
			}
			else if (to != from){
				a = now;
				b = to;

			}
		}
	}
}
int main(void){
	cin >> n;
	adj.resize(n);
	color.resize(n,-1);
	rT(i, n){
		cin >> a >> b; a--; b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	bfs();
	int res = INF;
	for (auto &v : adj)
		res = min(res, (int)v.size());
	cout << res << " ";
	if ((color[a] & 1) != (color[b] & 1))cout << n << endl;
	else cout << n - 1 << endl;
	return(0);
}

Submission Info

Submission Time
Task C - 最小カットと最大カット
User btk15049
Language C++11 (GCC 4.9.2)
Score 100
Code Size 2129 Byte
Status AC
Exec Time 199 ms
Memory 9756 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 29
Set Name Test Cases
All scrambled_00.txt, scrambled_01.txt, scrambled_02.txt, scrambled_03.txt, scrambled_04.txt, scrambled_05.txt, scrambled_06.txt, scrambled_07.txt, scrambled_08.txt, scrambled_09.txt, scrambled_10.txt, scrambled_11.txt, scrambled_12.txt, scrambled_13.txt, scrambled_14.txt, scrambled_15.txt, scrambled_16.txt, scrambled_17.txt, scrambled_18.txt, scrambled_19.txt, scrambled_20.txt, scrambled_21.txt, scrambled_22.txt, scrambled_23.txt, scrambled_24.txt, scrambled_25.txt, scrambled_26.txt, scrambled_27.txt, scrambled_28.txt
Case Name Status Exec Time Memory
scrambled_00.txt AC 24 ms 916 KB
scrambled_01.txt AC 25 ms 800 KB
scrambled_02.txt AC 26 ms 800 KB
scrambled_03.txt AC 194 ms 8992 KB
scrambled_04.txt AC 190 ms 9000 KB
scrambled_05.txt AC 118 ms 5788 KB
scrambled_06.txt AC 81 ms 3864 KB
scrambled_07.txt AC 166 ms 8228 KB
scrambled_08.txt AC 68 ms 3240 KB
scrambled_09.txt AC 85 ms 4140 KB
scrambled_10.txt AC 174 ms 9756 KB
scrambled_11.txt AC 80 ms 4136 KB
scrambled_12.txt AC 141 ms 7976 KB
scrambled_13.txt AC 133 ms 7456 KB
scrambled_14.txt AC 199 ms 9252 KB
scrambled_15.txt AC 135 ms 6684 KB
scrambled_16.txt AC 77 ms 3876 KB
scrambled_17.txt AC 79 ms 3880 KB
scrambled_18.txt AC 193 ms 9124 KB
scrambled_19.txt AC 36 ms 1444 KB
scrambled_20.txt AC 120 ms 5924 KB
scrambled_21.txt AC 77 ms 3872 KB
scrambled_22.txt AC 136 ms 6564 KB
scrambled_23.txt AC 89 ms 4260 KB
scrambled_24.txt AC 84 ms 4100 KB
scrambled_25.txt AC 101 ms 4904 KB
scrambled_26.txt AC 84 ms 4060 KB
scrambled_27.txt AC 123 ms 5924 KB
scrambled_28.txt AC 107 ms 5412 KB