Submission #527113

# Submission time Handle Problem Language Result Execution time Memory
527113 2022-02-17T02:06:57 Z maomao90 Potemkin cycle (CEOI15_indcyc) C++17
20 / 100
340 ms 5576 KB
#include <bits/stdc++.h>
using namespace std;

#define REP(i, j, k) for (int i = j; i < k; i++)
#define RREP(i, j, k) for (int i = j; i >= k; i--)

template<class T>
inline bool mxto(T &a, T b) {return a < b ? a = b, 1 : 0;}
template<class T>
inline bool mnto(T &a, T b) {return a > b ? a = b, 1 : 0;}

typedef long long ll;
#define FI first
#define SE second
#define MP make_pair
typedef pair<int, int> ii;
#define pb push_back
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<ii> vii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

#define MAXN 1005
#define INF 1000000005
#define LINF 1000000000000000005ll

int n, r;
vi adj[MAXN];
int grid[MAXN][MAXN];
vii eg;

int uf[MAXN], rnk[MAXN];
int findp(int i) {
	if (uf[i] == i) return i;
	return uf[i] = findp(uf[i]);
}
bool join(int a, int b) {
	int pa = findp(a), pb = findp(b);
	if (pa == pb) return 0;
	if (rnk[pa] < rnk[pb]) swap(pa, pb);
	if (rnk[pa] == rnk[pb]) rnk[pa]++;
	uf[pb] = pa;
	return 1;
}

int main() {
#ifndef DEBUG
	ios::sync_with_stdio(0), cin.tie(0);
#endif
	cin >> n >> r;
	REP (i, 0, n + 1) {
		uf[i] = i;
	}
	REP (i, 0, r) {
		int a, b; cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
		grid[a][b] = grid[b][a] = 1;
		eg.pb(MP(a, b));
	}
	for (auto [a, b] : eg) {
		REP (i, 1, n + 1) {
			if (grid[i][a] == 1 && grid[i][b] == 1) {
				join(i, a);
				join(i, b);
			}
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Too short sequence
2 Incorrect 1 ms 348 KB Unexpected end of file - token expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Too short sequence
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Too short sequence
2 Incorrect 1 ms 332 KB Unexpected end of file - token expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Too short sequence
# Verdict Execution time Memory Grader output
1 Correct 2 ms 716 KB Too short sequence
2 Incorrect 1 ms 760 KB Unexpected end of file - token expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1612 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1612 KB Too short sequence
2 Incorrect 4 ms 1616 KB Unexpected end of file - token expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 166 ms 5576 KB Too short sequence
2 Correct 47 ms 4940 KB Too short sequence
3 Incorrect 139 ms 5524 KB Unexpected end of file - token expected
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 66 ms 4940 KB Too short sequence
2 Incorrect 61 ms 4836 KB Unexpected end of file - token expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 334 ms 4524 KB Too short sequence
2 Incorrect 340 ms 4540 KB Unexpected end of file - token expected
3 Halted 0 ms 0 KB -