Submission #343477

#TimeUsernameProblemLanguageResultExecution timeMemory
343477leinad2The Potion of Great Power (CEOI20_potion)C++17
Compilation error
0 ms0 KiB
using namespace std; int n, d, H[100010], i, j, u, A[200010], B[200010], b, x, a; set<int>adj[100010][450], F[100010], X; set<int>::iterator it, it2; void init(int N, int D, int HH[]) { n=N; d=D; for(i=0;i<n;i++)H[i]=HH[i]; } void curseChanges(int U, int C[], int D[]) { u=U; for(i=0;i++<u;)A[i]=C[i-1],B[i]=D[i-1]; b=(int)round(sqrt(u)); for(i=0;i++<u;) { if(F[B[i]].find(A[i])==F[B[i]].end()) { F[A[i]].insert(B[i]); F[B[i]].insert(A[i]); } else { F[A[i]].erase(B[i]); F[B[i]].erase(A[i]); } if(i%b==0) { for(j=0;j<n;j++) { for(it=F[j].begin();it!=F[j].end();it++) { adj[j][i/b].insert(*it); } } } } } int question(int s, int e, int v) { x=v/b; for(i=b*x+1;i<=v;i++) { if(adj[B[i]][x].find(A[i])==adj[B[i]][x].end()) { adj[A[i]][x].insert(B[i]); adj[B[i]][x].insert(A[i]); } else { adj[A[i]][x].erase(B[i]); adj[B[i]][x].erase(A[i]); } } int ans=1e9; if(adj[s][x].size()==0||adj[e][x].size()==0) { goto w; } X.clear(); for(it=adj[s][x].begin();it!=adj[s][x].end();it++) { X.insert(H[*it]); } for(it=adj[e][x].begin();it!=adj[e][x].end();it++) { it2=X.lower_bound(H[*it]); if(it2==X.end())it2--; ans=min(ans, abs(H[*it]-*it2)); if(it2==X.begin())continue; it2--; ans=min(ans, abs(H[*it]-*it2)); } w:; for(i=v;i>b*x;i--) { if(adj[B[i]][x].find(A[i])==adj[B[i]][x].end()) { adj[A[i]][x].insert(B[i]); adj[B[i]][x].insert(A[i]); } else { adj[A[i]][x].erase(B[i]); adj[B[i]][x].erase(A[i]); } } return ans; }

Compilation message (stderr)

potion.cpp:3:1: error: 'set' does not name a type
    3 | set<int>adj[100010][450], F[100010], X;
      | ^~~
potion.cpp:4:1: error: 'set' does not name a type
    4 | set<int>::iterator it, it2;
      | ^~~
potion.cpp: In function 'void curseChanges(int, int*, int*)':
potion.cpp:15:18: error: 'sqrt' was not declared in this scope
   15 |     b=(int)round(sqrt(u));
      |                  ^~~~
potion.cpp:15:12: error: 'round' was not declared in this scope
   15 |     b=(int)round(sqrt(u));
      |            ^~~~~
potion.cpp:18:12: error: 'F' was not declared in this scope
   18 |         if(F[B[i]].find(A[i])==F[B[i]].end())
      |            ^
potion.cpp:32:21: error: 'it' was not declared in this scope; did you mean 'i'?
   32 |                 for(it=F[j].begin();it!=F[j].end();it++)
      |                     ^~
      |                     i
potion.cpp:32:24: error: 'F' was not declared in this scope
   32 |                 for(it=F[j].begin();it!=F[j].end();it++)
      |                        ^
potion.cpp:34:21: error: 'adj' was not declared in this scope
   34 |                     adj[j][i/b].insert(*it);
      |                     ^~~
potion.cpp: In function 'int question(int, int, int)':
potion.cpp:45:12: error: 'adj' was not declared in this scope
   45 |         if(adj[B[i]][x].find(A[i])==adj[B[i]][x].end())
      |            ^~~
potion.cpp:57:8: error: 'adj' was not declared in this scope
   57 |     if(adj[s][x].size()==0||adj[e][x].size()==0)
      |        ^~~
potion.cpp:61:5: error: 'X' was not declared in this scope
   61 |     X.clear();
      |     ^
potion.cpp:62:9: error: 'it' was not declared in this scope; did you mean 'i'?
   62 |     for(it=adj[s][x].begin();it!=adj[s][x].end();it++)
      |         ^~
      |         i
potion.cpp:62:12: error: 'adj' was not declared in this scope
   62 |     for(it=adj[s][x].begin();it!=adj[s][x].end();it++)
      |            ^~~
potion.cpp:66:9: error: 'it' was not declared in this scope; did you mean 'i'?
   66 |     for(it=adj[e][x].begin();it!=adj[e][x].end();it++)
      |         ^~
      |         i
potion.cpp:66:12: error: 'adj' was not declared in this scope
   66 |     for(it=adj[e][x].begin();it!=adj[e][x].end();it++)
      |            ^~~
potion.cpp:68:9: error: 'it2' was not declared in this scope
   68 |         it2=X.lower_bound(H[*it]);
      |         ^~~
potion.cpp:70:22: error: 'abs' was not declared in this scope; did you mean 'ans'?
   70 |         ans=min(ans, abs(H[*it]-*it2));
      |                      ^~~
      |                      ans
potion.cpp:70:13: error: 'min' was not declared in this scope
   70 |         ans=min(ans, abs(H[*it]-*it2));
      |             ^~~
potion.cpp:78:12: error: 'adj' was not declared in this scope
   78 |         if(adj[B[i]][x].find(A[i])==adj[B[i]][x].end())
      |            ^~~