Submission #1258084

#TimeUsernameProblemLanguageResultExecution timeMemory
1258084mquangPotemkin cycle (CEOI15_indcyc)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define TIME (1.0 * clock() / CLOCKS_PER_SEC) const int INF = 1e18, N = 1e3 + 5, MOD = 1e9 + 7; vector<int> g[N]; bool chk[N][N], vis[N]; int dist[N], par[N], qu[N], cnt; void dfs(int u, int p){ if (u == p || vis[u]) return; vis[u] = true; if(chk[u][p]){ qu[cnt++] = u; return; } for(int v : g[u]) dfs(v, p); } int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); int n, m; cin >> n >> m; while(m--){ int u, v; cin >> u >> v; u--, v--; g[u].push_back(v); g[v].push_back(u); chk[u][v] = chk[v][u] = true; } for(int i = 0; i < n; i++){ for(int i1 = 0; i1 < n; i1++) vis[i1] = false; vis[i] = true; for(int i1 = 0; i1 < n; i1++) if(!chk[i1][i] && !vis[i1]){ cnt = 0, dfs(i1, i); for(int z = 0; z < cnt; z++){ int s = qu[z]; for(int h = z + 1; h < cnt; h++){ int t = qu[h]; if(!chk[s][t]){ for(int i2 = 0; i2 < n; i2++) dist[i2] = n; int cnt = 0; dist[s] = 0; par[s] = -1; qu[cnt++] = s; for(int h = 0; h < cnt; h++){ int u = qu[h], d = dist[i1] + 1; for(int v : g[u]){ if(v != i && (v == t || !chk[v][i]) && dist[v] == n){ dist[v] = d; par[v] = u; qu[cnt++] = v; } } } cout << s + 1 << ' ' << i + 1; for(int i2 = t; i2 != s; i2 = par[i2]) cout << ' ' << i2 + 1; cout << '\n'; return 0; } } } } } cout << "no"; cerr << "Time: " << TIME; return 0; }#include <bits/stdc++.h> using namespace std; #define int long long #define TIME (1.0 * clock() / CLOCKS_PER_SEC) const int INF = 1e18, N = 1e3 + 5, MOD = 1e9 + 7; vector<int> g[N]; bool chk[N][N], vis[N]; int dist[N], par[N], qu[N], cnt; void dfs(int u, int p){ if (u == p || vis[u]) return; vis[u] = true; if(chk[u][p]){ qu[cnt++] = u; return; } for(int v : g[u]) dfs(v, p); } int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); int n, m; cin >> n >> m; while(m--){ int u, v; cin >> u >> v; u--, v--; g[u].push_back(v); g[v].push_back(u); chk[u][v] = chk[v][u] = true; } for(int i = 0; i < n; i++){ for(int i1 = 0; i1 < n; i1++) vis[i1] = false; vis[i] = true; for(int i1 = 0; i1 < n; i1++) if(!chk[i1][i] && !vis[i1]){ cnt = 0, dfs(i1, i); for(int z = 0; z < cnt; z++){ int s = qu[z]; for(int h = z + 1; h < cnt; h++){ int t = qu[h]; if(!chk[s][t]){ for(int i2 = 0; i2 < n; i2++) dist[i2] = n; int cnt = 0; dist[s] = 0; par[s] = -1; qu[cnt++] = s; for(int h = 0; h < cnt; h++){ int u = qu[h], d = dist[i1] + 1; for(int v : g[u]){ if(v != i && (v == t || !chk[v][i]) && dist[v] == n){ dist[v] = d; par[v] = u; qu[cnt++] = v; } } } cout << s + 1 << ' ' << i + 1; for(int i2 = t; i2 != s; i2 = par[i2]) cout << ' ' << i2 + 1; cout << '\n'; return 0; } } } } } cout << "no"; cerr << "Time: " << TIME; return 0; }

Compilation message (stderr)

indcyc.cpp:68:2: error: stray '#' in program
   68 | }#include <bits/stdc++.h>
      |  ^
indcyc.cpp:68:12: error: 'bits' was not declared in this scope
   68 | }#include <bits/stdc++.h>
      |            ^~~~
indcyc.cpp:68:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   68 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
indcyc.cpp:68:12: error: 'bits' was not declared in this scope
   68 | }#include <bits/stdc++.h>
      |            ^~~~
indcyc.cpp:68:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   68 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
indcyc.cpp:68:12: error: 'bits' was not declared in this scope
   68 | }#include <bits/stdc++.h>
      |            ^~~~
indcyc.cpp:68:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   68 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
indcyc.cpp:68:12: error: 'bits' was not declared in this scope
   68 | }#include <bits/stdc++.h>
      |            ^~~~
indcyc.cpp:68:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   68 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
indcyc.cpp:68:12: error: 'bits' was not declared in this scope
   68 | }#include <bits/stdc++.h>
      |            ^~~~
indcyc.cpp:68:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   68 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
indcyc.cpp:68:12: error: 'bits' was not declared in this scope
   68 | }#include <bits/stdc++.h>
      |            ^~~~
indcyc.cpp:68:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   68 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
indcyc.cpp:68:12: error: 'bits' was not declared in this scope
   68 | }#include <bits/stdc++.h>
      |            ^~~~
indcyc.cpp:68:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   68 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
indcyc.cpp:68:12: error: 'bits' was not declared in this scope
   68 | }#include <bits/stdc++.h>
      |            ^~~~
indcyc.cpp:68:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   68 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
indcyc.cpp:68:12: error: 'bits' was not declared in this scope
   68 | }#include <bits/stdc++.h>
      |            ^~~~
indcyc.cpp:68:17: error: 'stdc' was not declared in this scope; did you mean 'std'?
   68 | }#include <bits/stdc++.h>
      |                 ^~~~
      |                 std
indcyc.cpp:68:3: error: 'include' does not name a type
   68 | }#include <bits/stdc++.h>
      |   ^~~~~~~
indcyc.cpp:72:11: error: redefinition of 'const long long int INF'
   72 | const int INF = 1e18, N = 1e3 + 5, MOD = 1e9 + 7;
      |           ^~~
indcyc.cpp:5:11: note: 'const long long int INF' previously defined here
    5 | const int INF = 1e18, N = 1e3 + 5, MOD = 1e9 + 7;
      |           ^~~
indcyc.cpp:72:23: error: redefinition of 'const long long int N'
   72 | const int INF = 1e18, N = 1e3 + 5, MOD = 1e9 + 7;
      |                       ^
indcyc.cpp:5:23: note: 'const long long int N' previously defined here
    5 | const int INF = 1e18, N = 1e3 + 5, MOD = 1e9 + 7;
      |                       ^
indcyc.cpp:72:36: error: redefinition of 'const long long int MOD'
   72 | const int INF = 1e18, N = 1e3 + 5, MOD = 1e9 + 7;
      |                                    ^~~
indcyc.cpp:5:36: note: 'const long long int MOD' previously defined here
    5 | const int INF = 1e18, N = 1e3 + 5, MOD = 1e9 + 7;
      |                                    ^~~
indcyc.cpp:73:13: error: redefinition of 'std::vector<long long int> g [1005]'
   73 | vector<int> g[N];
      |             ^
indcyc.cpp:6:13: note: 'std::vector<long long int> g [1005]' previously declared here
    6 | vector<int> g[N];
      |             ^
indcyc.cpp:74:6: error: redefinition of 'bool chk [1005][1005]'
   74 | bool chk[N][N], vis[N];
      |      ^~~
indcyc.cpp:7:6: note: 'bool chk [1005][1005]' previously declared here
    7 | bool chk[N][N], vis[N];
      |      ^~~
indcyc.cpp:74:17: error: redefinition of 'bool vis [1005]'
   74 | bool chk[N][N], vis[N];
      |                 ^~~
indcyc.cpp:7:17: note: 'bool vis [1005]' previously declared here
    7 | bool chk[N][N], vis[N];
      |                 ^~~
indcyc.cpp:75:5: error: redefinition of 'long long int dist [1005]'
   75 | int dist[N], par[N], qu[N], cnt;
      |     ^~~~
indcyc.cpp:8:5: note: 'long long int dist [1005]' previously declared here
    8 | int dist[N], par[N], qu[N], cnt;
      |     ^~~~
indcyc.cpp:75:14: error: redefinition of 'long long int par [1005]'
   75 | int dist[N], par[N], qu[N], cnt;
      |              ^~~
indcyc.cpp:8:14: note: 'long long int par [1005]' previously declared here
    8 | int dist[N], par[N], qu[N], cnt;
      |              ^~~
indcyc.cpp:75:22: error: redefinition of 'long long int qu [1005]'
   75 | int dist[N], par[N], qu[N], cnt;
      |                      ^~
indcyc.cpp:8:22: note: 'long long int qu [1005]' previously declared here
    8 | int dist[N], par[N], qu[N], cnt;
      |                      ^~
indcyc.cpp:75:29: error: redefinition of 'long long int cnt'
   75 | int dist[N], par[N], qu[N], cnt;
      |                             ^~~
indcyc.cpp:8:29: note: 'long long int cnt' previously declared here
    8 | int dist[N], par[N], qu[N], cnt;
      |                             ^~~
indcyc.cpp:76:6: error: redefinition of 'void dfs(long long int, long long int)'
   76 | void dfs(int u, int p){
      |      ^~~
indcyc.cpp:9:6: note: 'void dfs(long long int, long long int)' previously defined here
    9 | void dfs(int u, int p){
      |      ^~~
indcyc.cpp:85:9: error: redefinition of 'int32_t main()'
   85 | int32_t main(){
      |         ^~~~
indcyc.cpp:18:9: note: 'int32_t main()' previously defined here
   18 | int32_t main(){
      |         ^~~~