답안 #129691

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
129691 2019-07-13T04:49:55 Z 윤교준(#3140) 전압 (JOI14_voltage) C++14
0 / 100
2 ms 380 KB
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define upmax(a,b) (a)=max((a),(b))
#define INF (0x3f3f3f3f)
using namespace std;
typedef pair<int, int> pii;

const int MAXN = 1005;
const int MAXM = 2005;

vector<int> G[MAXN];

int A[MAXM], B[MAXM];

int N, M, Ans;

bitset<MAXN> chk, isb;
bool dfs(int i, int X) {
	chk[i] = true;
	for(int e : G[i]) {
		int v = A[e]^B[e]^i;
		if(e != X) {
			if(chk[v]) {
				if(isb[v] == isb[i]) return false;
				continue;
			}
			isb[v] = !isb[i];
		} else {
			if(chk[v]) {
				if(isb[v] != isb[i]) return false;
				continue;
			}
			isb[v] = isb[i];
		}
		if(!dfs(v, X)) return false;
	}
	return true;
}
bool isp(int X) {
	chk.reset(); isb.reset();
	for(int i = 1; i <= N; i++) if(!chk[i])
		if(!dfs(i, X)) return false;
	return true;
}

int main() {
	ios::sync_with_stdio(false);

	cin >> N >> M;
	cout << ((M&1) ? M : 0) << endl;
	return 0;
	for(int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i];
		G[A[i]].eb(i);
		G[B[i]].eb(i);
	}

	for(int i = 1; i <= M; i++)
		if(isp(i)) Ans++;

	cout << Ans << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 296 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -