Submission #32840

#TimeUsernameProblemLanguageResultExecution timeMemory
32840imaxbluePipes (CEOI15_pipes)C++14
Compilation error
0 ms0 KiB
#include<cstdio> #include<vector> using namespace std; #define pb push_back #define fox(k, x) for (int k=0; k<x; ++k) #define fox1(k, x) for (int k=1; k<=x; ++k) #define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0) char _; int n, m, t, a, b, X2, Y2, P, X, Y r[100001], p[100001], h[100001], d[100001]; bool u[100001]; vector<int> com[100001]; inline bool mrg(int A, int B){ if (A==B) return 0; if (com[A].size()<com[B].size()) return mrg(B, A); for (auto i:com[B]){ com[A].pb(i); r[i]=A; } return 1; } void dfs(int N, int P){ if ((p[N]=P)>0) d[N]=d[P]+1; fox(l, com[N].size()){ if (com[N][l]==P) continue; dfs(com[N][l], N); } } void lca(int X, int Y){ } int q[100001]; int main(){ scan(n); scan(m); fox1(l, n){ com[r[l]=l].clear(); com[l].pb(l); } fox(l, m){ scan(a); scan(b); if (mrg(r[a], r[b])){ h[P]=a; d[P]=b; q[P++]=l; } } fox1(l, n) com[l].clear(); fox(l, P){ com[h[l]].pb(d[l]); com[d[l]].pb(h[l]); } fox1(l, n) if (!p[l]) dfs(l, -1); fox1(l, n){ r[l]=l; h[l]=l; com[l].clear(); com[l].pb(l); } P=0; rewind(stdin); scan(n); scan(m); fox(l, m){ scan(a); scan(b); if (l==q[P]) ++P; else { X=r[a]; Y=r[b]; while(X!=Y){ if (d[X2=h[X]]>d[Y2=h[Y]]){ u[X2]=1; t=h[r[p[X2]]]; mrg(X, r[p[X2]]); h[X]=t; } else { u[Y2]=1; t=h[r[p[Y2]]]; mrg(Y, r[p[Y2]]); h[Y]=t; } X=r[X]; Y=r[Y]; } } } fox1(l, n){ if (!u[l] && p[l]>0){ printf("%i %i\n", l, p[l]); } } return 0; }

Compilation message (stderr)

pipes.cpp:12:5: error: expected initializer before 'r'
     r[100001], p[100001], h[100001], d[100001];
     ^
pipes.cpp: In function 'bool mrg(int, int)':
pipes.cpp:20:9: error: 'r' was not declared in this scope
         r[i]=A;
         ^
pipes.cpp: In function 'void dfs(int, int)':
pipes.cpp:25:10: error: 'p' was not declared in this scope
     if ((p[N]=P)>0) d[N]=d[P]+1;
          ^
pipes.cpp:25:21: error: 'd' was not declared in this scope
     if ((p[N]=P)>0) d[N]=d[P]+1;
                     ^
pipes.cpp:5:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define fox(k, x) for (int k=0; k<x; ++k)
pipes.cpp:26:9:
     fox(l, com[N].size()){
         ~~~~~~~~~~~~~~~~          
pipes.cpp:26:5: note: in expansion of macro 'fox'
     fox(l, com[N].size()){
     ^~~
pipes.cpp: In function 'int main()':
pipes.cpp:37:13: error: 'r' was not declared in this scope
         com[r[l]=l].clear(); com[l].pb(l);
             ^
pipes.cpp:41:17: error: 'r' was not declared in this scope
         if (mrg(r[a], r[b])){
                 ^
pipes.cpp:42:13: error: 'h' was not declared in this scope
             h[P]=a;
             ^
pipes.cpp:43:13: error: 'd' was not declared in this scope
             d[P]=b;
             ^
pipes.cpp:50:13: error: 'h' was not declared in this scope
         com[h[l]].pb(d[l]);
             ^
pipes.cpp:50:22: error: 'd' was not declared in this scope
         com[h[l]].pb(d[l]);
                      ^
pipes.cpp:54:14: error: 'p' was not declared in this scope
         if (!p[l]) dfs(l, -1);
              ^
pipes.cpp:56:9: error: 'r' was not declared in this scope
         r[l]=l; h[l]=l;
         ^
pipes.cpp:56:17: error: 'h' was not declared in this scope
         r[l]=l; h[l]=l;
                 ^
pipes.cpp:66:15: error: 'r' was not declared in this scope
             X=r[a]; Y=r[b];
               ^
pipes.cpp:66:21: error: 'Y' was not declared in this scope
             X=r[a]; Y=r[b];
                     ^
pipes.cpp:68:21: error: 'd' was not declared in this scope
                 if (d[X2=h[X]]>d[Y2=h[Y]]){
                     ^
pipes.cpp:68:26: error: 'h' was not declared in this scope
                 if (d[X2=h[X]]>d[Y2=h[Y]]){
                          ^
pipes.cpp:70:27: error: 'p' was not declared in this scope
                     t=h[r[p[X2]]];
                           ^
pipes.cpp:75:27: error: 'p' was not declared in this scope
                     t=h[r[p[Y2]]];
                           ^
pipes.cpp:84:22: error: 'p' was not declared in this scope
         if (!u[l] && p[l]>0){
                      ^