# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
95855 | 2019-02-03T07:32:54 Z | Kastanda | Potemkin cycle (CEOI15_indcyc) | C++11 | 983 ms | 1400 KB |
#include<bits/stdc++.h> using namespace std; const int N = 1009; int n, m, qu[N], P[N]; bitset < N > M, S, is[N]; vector < int > Adj[N]; inline void Prnt(int fxd, int v, int u) { M = S = 0; memset(P, 0, sizeof(P)); for (int &w : Adj[fxd]) M[w] = 1; int l = 0, r = 0; qu[r ++] = v; S[v] = 1; while (r - l) { int nw = qu[l ++]; for (int &w : Adj[nw]) if (w != fxd && !S[w] && !(M[nw] && M[w])) { S[w] = 1; P[w] = nw; if (!M[w]) qu[r ++] = w; } } if (P[u] == 0) return ; vector < int > A; A.push_back(fxd); for (; u; u = P[u]) A.push_back(u); for (int i = 0; i < (int)A.size(); i++) for (int j = i + 2; j < (int)A.size(); j++) if ((i != 0 || j != (int)A.size() - 1) && is[A[i]][A[j]]) assert(0); for (int a : A) printf("%d ", a); printf("\n"); exit(0); } int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { int v, u; scanf("%d%d", &v, &u); Adj[v].push_back(u); Adj[u].push_back(v); is[v][u] = is[u][v] = 1; } srand(time(0)); for (int i = 1; i <= n; i++) random_shuffle(Adj[i].begin(), Adj[i].end()); for (int fxd = 1; fxd <= n; fxd ++) { if (clock() >= CLOCKS_PER_SEC * 0.89) return !printf("no\n"); M = S = 0; for (int &v : Adj[fxd]) M[v] = 1; for (int &v : Adj[fxd]) { int l = 0, r = 0; qu[r ++] = v; vector < int > A = {v}; S[v] = 1; while (r - l) { int u = qu[l ++]; for (int &w : Adj[u]) if (w != fxd && !S[w] && !(M[u] && M[w])) { S[w] = 1; if (M[w]) A.push_back(w); else qu[r ++] = w; } } for (int i = 0; i < (int)A.size(); i++) for (int j = i + 1; j < (int)A.size(); j++) if (!is[A[i]][A[j]]) Prnt(fxd, A[i], A[j]); } } return !printf("no\n"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 4 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 504 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
3 | Correct | 4 ms | 504 KB | Output is correct |
4 | Correct | 14 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 504 KB | Output is correct |
2 | Correct | 25 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 1016 KB | Output is correct |
2 | Correct | 8 ms | 764 KB | Output is correct |
3 | Correct | 191 ms | 1016 KB | Output is correct |
4 | Correct | 99 ms | 824 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 760 KB | Output is correct |
2 | Correct | 983 ms | 888 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 1400 KB | Output is correct |
2 | Correct | 404 ms | 1400 KB | Output is correct |
3 | Correct | 27 ms | 1144 KB | Output is correct |
4 | Correct | 447 ms | 1272 KB | Output is correct |