Submission #1035174

#TimeUsernameProblemLanguageResultExecution timeMemory
1035174vjudge1Pipes (CEOI15_pipes)C++98
Compilation error
0 ms0 KiB
#pragma GCC optimize("O3,unroll-loops") #include <iostream> #include <vector> using namespace std; const int N = 1e5+1; struct dsu { vt<int> e(N); int find(int &x) { return e[x] < 0 ? x : e[x] = find(e[x]); } bool join(int a, int b) { a = find(a), b = find(b); if (a == b) return false; if (e[a] > e[b]) swap(a, b); e[a] += e[b]; e[b] = a; return true; } } d1, d2; vector<int> g[N]; int timer=0; void dfs(int at, int par) { d1.e[at]=d2.e[at]=++timer; for(int &to:g[at]) { if(to == par) { par+=N; continue; } if(d2.e[to]) { d1.e[at]=min(d1.e[at], d2.e[to]); } else { dfs(to, at); d1.e[at]=min(d1.e[at], d1.e[to]); } } if(par>N)par-=N; if(d1.e[at] == d2.e[at] and at!=par) { printf("%d %d\n", at, par); } } int n, m, u, v; int main() { srand(time(0)); scanf("%d %d", &n, &m); //nt u, v; for(int i = 1;i<N;i++)d1.e[i]=d2.e[i]=-1; for(int i = 0;i<m;i++) { scanf("%d %d", &u, &v); if((d1.join(u, v) || d2.join(u, v))) { g[u].push_back(v); g[v].push_back(u); } } for(int i = 1;i<N;i++)d1.e[i]=d2.e[i]=0; for(int i= 1;i<=n;i++) { if(!d1.e[i]) { dfs(i, i); } } }

Compilation message (stderr)

pipes.cpp:8:2: error: 'vt' does not name a type
    8 |  vt<int> e(N);
      |  ^~
pipes.cpp: In member function 'int dsu::find(int&)':
pipes.cpp:9:28: error: 'e' was not declared in this scope
    9 |  int find(int &x) { return e[x] < 0 ? x : e[x] = find(e[x]); }
      |                            ^
pipes.cpp: In member function 'bool dsu::join(int, int)':
pipes.cpp:13:7: error: 'e' was not declared in this scope
   13 |   if (e[a] > e[b]) swap(a, b);
      |       ^
pipes.cpp:14:3: error: 'e' was not declared in this scope
   14 |   e[a] += e[b]; e[b] = a;
      |   ^
pipes.cpp: In function 'void dfs(int, int)':
pipes.cpp:21:5: error: 'struct dsu' has no member named 'e'
   21 |  d1.e[at]=d2.e[at]=++timer;
      |     ^
pipes.cpp:21:14: error: 'struct dsu' has no member named 'e'
   21 |  d1.e[at]=d2.e[at]=++timer;
      |              ^
pipes.cpp:27:9: error: 'struct dsu' has no member named 'e'
   27 |   if(d2.e[to]) {
      |         ^
pipes.cpp:28:7: error: 'struct dsu' has no member named 'e'
   28 |    d1.e[at]=min(d1.e[at], d2.e[to]);
      |       ^
pipes.cpp:28:20: error: 'struct dsu' has no member named 'e'
   28 |    d1.e[at]=min(d1.e[at], d2.e[to]);
      |                    ^
pipes.cpp:28:30: error: 'struct dsu' has no member named 'e'
   28 |    d1.e[at]=min(d1.e[at], d2.e[to]);
      |                              ^
pipes.cpp:31:7: error: 'struct dsu' has no member named 'e'
   31 |    d1.e[at]=min(d1.e[at], d1.e[to]);
      |       ^
pipes.cpp:31:20: error: 'struct dsu' has no member named 'e'
   31 |    d1.e[at]=min(d1.e[at], d1.e[to]);
      |                    ^
pipes.cpp:31:30: error: 'struct dsu' has no member named 'e'
   31 |    d1.e[at]=min(d1.e[at], d1.e[to]);
      |                              ^
pipes.cpp:35:8: error: 'struct dsu' has no member named 'e'
   35 |  if(d1.e[at] == d2.e[at] and at!=par) {
      |        ^
pipes.cpp:35:20: error: 'struct dsu' has no member named 'e'
   35 |  if(d1.e[at] == d2.e[at] and at!=par) {
      |                    ^
pipes.cpp: In function 'int main()':
pipes.cpp:45:27: error: 'struct dsu' has no member named 'e'
   45 |  for(int i = 1;i<N;i++)d1.e[i]=d2.e[i]=-1;
      |                           ^
pipes.cpp:45:35: error: 'struct dsu' has no member named 'e'
   45 |  for(int i = 1;i<N;i++)d1.e[i]=d2.e[i]=-1;
      |                                   ^
pipes.cpp:53:27: error: 'struct dsu' has no member named 'e'
   53 |  for(int i = 1;i<N;i++)d1.e[i]=d2.e[i]=0;
      |                           ^
pipes.cpp:53:35: error: 'struct dsu' has no member named 'e'
   53 |  for(int i = 1;i<N;i++)d1.e[i]=d2.e[i]=0;
      |                                   ^
pipes.cpp:55:10: error: 'struct dsu' has no member named 'e'
   55 |   if(!d1.e[i]) {
      |          ^
pipes.cpp:43:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |  scanf("%d %d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~
pipes.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |   scanf("%d %d", &u, &v);
      |   ~~~~~^~~~~~~~~~~~~~~~~