Submission #478970

#TimeUsernameProblemLanguageResultExecution timeMemory
478970hjc4vrPipes (CEOI15_pipes)C++14
Compilation error
0 ms0 KiB
using namespace std; int ufds1[100005],ufds2[100005],low[100005],depths[100005]; vector<int> adj[100005]; int find(int a,int par[]){ if (par[a]==a) return a; par[a] = find(par[a],par); return par[a]; } void dfs(int cur,int par){ depths[cur] = depths[par] + 1; low[cur] = depths[cur]; bool check= false; for (auto it: adj[cur]){ if (check == false && it==par){ check = true; continue; } else{ if (depths[it]==-1){ dfs(it,cur); low[cur] = min(low[cur],low[it]); if (low[it]>depths[cur]){ cout << cur << ' ' << it << '\n'; } }else{ low[cur] = min(low[cur],depths[it]); } } } } int32_t main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n,m;cin>>n>>m; fill(depths,depths+100005,-1); for (int i=1;i<=n;++i){ ufds1[i] = i; ufds2[i] = i; } for (int i=0;i<m;++i){ int a,b;cin>>a>>b; int pa = find(a,ufds1), pb = find(b,ufds1); if (pa!=pb){ adj[a].push_back(b); adj[b].push_back(a); ufds1[pb] = pa; }else{ // it is a back edge int ba = find(a,ufds2), bb = find(b,ufds2); if (ba!=bb){ adj[a].push_back(b); adj[b].push_back(a); ufds2[bb] = ba; } } } for (int i=1;i<=n;++i){ if (depths[i]==-1){ dfs(i,0); } } } // //4 //4 //2 //2 //2 //4 //4 //4 //4 //2 //4 //4 //2

Compilation message (stderr)

pipes.cpp:3:1: error: 'vector' does not name a type
    3 | vector<int> adj[100005];
      | ^~~~~~
pipes.cpp: In function 'void dfs(int, int)':
pipes.cpp:14:19: error: 'adj' was not declared in this scope
   14 |     for (auto it: adj[cur]){
      |                   ^~~
pipes.cpp:22:24: error: 'min' was not declared in this scope
   22 |             low[cur] = min(low[cur],low[it]);
      |                        ^~~
pipes.cpp:24:17: error: 'cout' was not declared in this scope
   24 |                 cout << cur << ' ' << it << '\n';
      |                 ^~~~
pipes.cpp:1:1: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
  +++ |+#include <iostream>
    1 | using namespace std;
pipes.cpp:27:24: error: 'min' was not declared in this scope
   27 |             low[cur] = min(low[cur],depths[it]);
      |                        ^~~
pipes.cpp: At global scope:
pipes.cpp:34:1: error: 'int32_t' does not name a type
   34 | int32_t main(){
      | ^~~~~~~