Submission #858506

#TimeUsernameProblemLanguageResultExecution timeMemory
858506Tenis0206ICC (CEOI16_icc)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int nmax = 100; #ifdef home pair<int,int> e[nmax + 5]; void output(string msg) { cout<<msg<<'\n'; exit(0); } int cnt = 1; int query(int sza, int szb, int a[], int b[]) { bool ok = false; for(int i=0;i<sza;i++) { for(int j=0;j<szb;j++) { for(int nr=1;nr<=cnt;nr++) { if(e[nr].first==a[i] && e[nr].second==b[i]) { ok = true; break; } if(e[nr].first==b[i] && e[nr].second==a[i]) { ok = true; break; } } } } return ok; } void setRoad(int a, int b) { bool ok = false; if(a==e[cnt].first && b==e[cnt].second) { ok = true; } if(a==e[cnt].second && b==e[cnt].first) { ok = true; } if(!ok) { output("Bad edge"); } ++cnt; } #endif // home int n; int a[nmax + 5], b[nmax + 5]; int vst[nmax + 5]; int t[nmax + 5]; vector<int> l[nmax + 5]; int rep(int x) { if(t[x]==x) { return x; } return rep(t[x]); } void uneste(int x, int y) { x = rep(x); y = rep(y); if(x==y) { return; } if(l[x].size() > l[y].size()) { for(auto it : l[y]) { l[x].push_back(it); } l[y].clear(); t[y] = x; } else { for(auto it : l[x]) { l[y].push_back(it); } l[x].clear(); t[x] = y; } } pair<int,int> find_dif(int nra, int nrb, int a[], int b[]) { int val_a = 0, val_b = 0; int st = 0; int dr = nra - 1; while(st<=dr) { int mij = (st + dr) >> 1; int nrv = 0; for(int i=st;i<=mij;i++) { vst[nrv++] = a[i]; } int ok = query(nrv, nrb, vst, b); if(ok) { dr = mij; } else { st = mij + 1; } } val_a = a[st]; st = 0; dr = nrb - 1; while(st<=dr) { int mij = (st + dr) >> 1; int nrv = 0; for(int i=st;i<=mij;i++) { vst[nrv++] = a[i]; } int ok = query(nrv, nra, vst, a); if(ok) { dr = mij; } else { st = mij + 1; } } val_b = b[st]; return {val_a, val_b}; } void find_new_edge() { vector<int> c; for(int i=1;i<=n;i++) { if(rep(i)==i) { c.push_back(i); } } pair<int,int> rez = {0,0}; for(int bit=0;(1<<bit)<c.size();bit++) { int nra = 0, nrb = 0; for(int i=0;i<c.size();i++) { if((i & (1<<bit)) == 0) { for(auto it : l[c[i]]) { a[nra++] = it; } } else { for(auto it : l[c[i]]) { b[nrb++] = it; } } } int ok = query(nra, nrb, a, b); if(ok) { rez = find_dif(nra, nrb, a, b); break; } } setRoad(rez.first,rez.second); uneste(rez.first, rez.second); } void run(int N) { n = N; for(int i=1;i<=n;i++) { t[i] = i; l[i].push_back(i); } for(int i=1;i<n;i++) { find_new_edge(); } } #ifdef home int main() { freopen("nr.in","r",stdin); freopen("nr.out","w",stdout); cin>>n; for(int i=1;i<n;i++) { int x,y; cin>>x>>y; e[i] = {x,y}; } output("OK"); return 0; } #endif // home

Compilation message (stderr)

icc.cpp: In function 'std::pair<int, int> find_dif(int, int, int*, int*)':
icc.cpp:122:18: error: 'query' was not declared in this scope
  122 |         int ok = query(nrv, nrb, vst, b);
      |                  ^~~~~
icc.cpp:144:18: error: 'query' was not declared in this scope
  144 |         int ok = query(nrv, nra, vst, a);
      |                  ^~~~~
icc.cpp: In function 'void find_new_edge()':
icc.cpp:170:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  170 |     for(int bit=0;(1<<bit)<c.size();bit++)
      |                   ~~~~~~~~^~~~~~~~~
icc.cpp:173:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  173 |         for(int i=0;i<c.size();i++)
      |                     ~^~~~~~~~~
icc.cpp:190:18: error: 'query' was not declared in this scope
  190 |         int ok = query(nra, nrb, a, b);
      |                  ^~~~~
icc.cpp:197:5: error: 'setRoad' was not declared in this scope
  197 |     setRoad(rez.first,rez.second);
      |     ^~~~~~~