# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
258201 | 2020-08-05T14:17:18 Z | doowey | Potemkin cycle (CEOI15_indcyc) | C++14 | 1000 ms | 2176 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int N = 1005; vector<int> T[N]; int id[N]; int cc; void dfs(int u){ id[u]=cc; for(auto x : T[u]){ if(id[x] == -1) dfs(x); } } vector<int> in[N]; bool has[N][N]; int las[N]; int dist[N]; bool mark[N]; int main(){ fastIO; int n, m; cin >> n >> m; int u, v; for(int i = 0 ; i < m ; i ++ ){ cin >> u >> v; T[u].push_back(v); T[v].push_back(u); has[u][v] = has[v][u] = true; } int node; int low, xi, yi; bool good; vector<int> ord; for(int i = 1; i <= n; i ++ ) ord.push_back(i); random_shuffle(ord.begin(), ord.end()); for(auto i : ord){ for(int j = 1; j <= n; j ++ ){ id[j]=-1; in[j].clear(); mark[j]=false; } id[i]=0; cc=1; for(auto x : T[i]){ mark[x]=true; if(id[x] == -1){ dfs(x); cc ++ ; } } for(auto x : T[i]){ in[id[x]].push_back(x); } for(int s = 1; s < cc; s ++ ){ low = (int)1e9, xi = -1, yi = -1; good = false; for(auto x : in[s]){ for(auto y : in[s]){ if(x==y || has[x][y]) continue; good=true; } } if(!good) continue; for(auto x : in[s]){ queue<int> bf; bf.push(x); for(int j = 1; j <= n; j ++ ){ las[j]=-1; dist[j]=(int)1e9; } dist[i]=0; dist[x] = 0; while(!bf.empty()){ node = bf.front(); bf.pop(); if(mark[node] && dist[node] == 1) continue; if(mark[node] && dist[node] > 0){ cout << i << " "; while(1){ cout << node << " "; if(node == x) break; node = las[node]; } return 0; } for(auto f : T[node]){ if(dist[f] > dist[node] + 1){ dist[f] = dist[node] + 1; las[f] = node; bf.push(f); } } } } } } cout << "no\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 512 KB | Output is correct |
2 | Correct | 5 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 816 KB | Output is correct |
2 | Correct | 2 ms | 768 KB | Output is correct |
3 | Correct | 3 ms | 768 KB | Output is correct |
4 | Correct | 73 ms | 768 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 768 KB | Output is correct |
2 | Correct | 28 ms | 768 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 1920 KB | Output is correct |
2 | Correct | 42 ms | 1664 KB | Output is correct |
3 | Execution timed out | 1066 ms | 1920 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 52 ms | 1664 KB | Output is correct |
2 | Correct | 881 ms | 1724 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 81 ms | 1912 KB | Output is correct |
2 | Correct | 178 ms | 1792 KB | Output is correct |
3 | Correct | 72 ms | 2140 KB | Output is correct |
4 | Execution timed out | 1072 ms | 2176 KB | Time limit exceeded |