Submission #776324

# Submission time Handle Problem Language Result Execution time Memory
776324 2023-07-07T16:32:37 Z I_Love_EliskaM_ Highway Tolls (IOI18_highway) C++14
Compilation error
0 ms 0 KB
void find(int n, vector<int>u, vector<int>v, int a, int b) {
  if (a!=1 || b!=2) exit(0);
  int m=u.size();
  vector<int> f,s;
  ll x;
  forn(it,18) {
    f.clear(), s.clear();
    vector<int> ok(n);
    forn(i,n) ok[i]=rng()&1;
    forn(i,n) (ok[i]?f:s).pb(i);
    if (min(f.size(),s.size())==0) {
      --it; continue;
    }
    vector<int> q(m,0);
    forn(i,m) q[i]=ok[u[i]]==ok[v[i]];
    x = ask(q);
    if (x&1) {
      break;
    }
  }
  if (!(x&1)) exit(0);
  if (f.size()>s.size());
  int l=0, r=f.size()-1;
  while (l<r) {
    int mid=(l+r)>>1;
    vector<int> ok(n);
    for(auto&x:s) ok[x]=1;
    forn(i,mid+1) ok[f[i]]=1;
    vector<int> q(m,0);
    forn(i,m) q[i]=ok[u[i]]==ok[v[i]];
    x = ask(q);
    if (x&1) l=mid+1;
    else r=mid;
  }
  int st = f[r];
  vector<vector<pi>> g(n);
  forn(i,m) {
    g[u[i]].pb({v[i],i});
    g[v[i]].pb({u[i],i});
  }
  vector<int> p(n);
  vector<int> vis(n); vis[st]=1;
  queue<int> q; q.push(st);
  while (q.size()) {
    auto u=q.front();q.pop();
    for(auto&ed:g[u]) {
      int v=ed.f, i=ed.s;
      if (vis[v]) continue;
      vis[v]=1;
      p[v]=i;
      e[i]={u,v};
      q.push(v);
      adj[u].pb({v,i});
    }
  }
  z.clear();
  dfs(st,-1);
  l=0, r=n-2;
  ll S=ask(vector<int>(m,1));
  while (l<r) {
    int mid=(l+r)>>1;
    vector<int> q(m);
    forn(i,mid+1) q[z[i]]=1;
    ll x=ask(q);
    if (x==S) r=mid;
    else l=mid+1;
  }
  answer(st,e[z[r]].s);

}

Compilation message

highway.cpp:1:18: error: 'vector' has not been declared
    1 | void find(int n, vector<int>u, vector<int>v, int a, int b) {
      |                  ^~~~~~
highway.cpp:1:24: error: expected ',' or '...' before '<' token
    1 | void find(int n, vector<int>u, vector<int>v, int a, int b) {
      |                        ^
highway.cpp: In function 'void find(int, int)':
highway.cpp:2:7: error: 'a' was not declared in this scope
    2 |   if (a!=1 || b!=2) exit(0);
      |       ^
highway.cpp:2:15: error: 'b' was not declared in this scope
    2 |   if (a!=1 || b!=2) exit(0);
      |               ^
highway.cpp:2:21: error: 'exit' was not declared in this scope
    2 |   if (a!=1 || b!=2) exit(0);
      |                     ^~~~
highway.cpp:3:9: error: 'u' was not declared in this scope
    3 |   int m=u.size();
      |         ^
highway.cpp:4:3: error: 'vector' was not declared in this scope
    4 |   vector<int> f,s;
      |   ^~~~~~
highway.cpp:4:10: error: expected primary-expression before 'int'
    4 |   vector<int> f,s;
      |          ^~~
highway.cpp:5:3: error: 'll' was not declared in this scope
    5 |   ll x;
      |   ^~
highway.cpp:6:8: error: 'it' was not declared in this scope; did you mean 'int'?
    6 |   forn(it,18) {
      |        ^~
      |        int
highway.cpp:6:3: error: 'forn' was not declared in this scope
    6 |   forn(it,18) {
      |   ^~~~
highway.cpp:21:9: error: 'x' was not declared in this scope
   21 |   if (!(x&1)) exit(0);
      |         ^
highway.cpp:21:15: error: 'exit' was not declared in this scope
   21 |   if (!(x&1)) exit(0);
      |               ^~~~
highway.cpp:22:7: error: 'f' was not declared in this scope
   22 |   if (f.size()>s.size());
      |       ^
highway.cpp:22:16: error: 's' was not declared in this scope
   22 |   if (f.size()>s.size());
      |                ^
highway.cpp:23:14: error: 'f' was not declared in this scope
   23 |   int l=0, r=f.size()-1;
      |              ^
highway.cpp:26:12: error: expected primary-expression before 'int'
   26 |     vector<int> ok(n);
      |            ^~~
highway.cpp:27:16: error: 's' was not declared in this scope
   27 |     for(auto&x:s) ok[x]=1;
      |                ^
highway.cpp:27:19: error: 'ok' was not declared in this scope
   27 |     for(auto&x:s) ok[x]=1;
      |                   ^~
highway.cpp:28:10: error: 'i' was not declared in this scope
   28 |     forn(i,mid+1) ok[f[i]]=1;
      |          ^
highway.cpp:29:12: error: expected primary-expression before 'int'
   29 |     vector<int> q(m,0);
      |            ^~~
highway.cpp:31:5: error: 'x' was not declared in this scope
   31 |     x = ask(q);
      |     ^
highway.cpp:31:13: error: 'q' was not declared in this scope
   31 |     x = ask(q);
      |             ^
highway.cpp:31:9: error: 'ask' was not declared in this scope
   31 |     x = ask(q);
      |         ^~~
highway.cpp:36:17: error: 'pi' was not declared in this scope
   36 |   vector<vector<pi>> g(n);
      |                 ^~
highway.cpp:36:22: error: 'g' was not declared in this scope
   36 |   vector<vector<pi>> g(n);
      |                      ^
highway.cpp:37:8: error: 'i' was not declared in this scope
   37 |   forn(i,m) {
      |        ^
highway.cpp:41:10: error: expected primary-expression before 'int'
   41 |   vector<int> p(n);
      |          ^~~
highway.cpp:42:10: error: expected primary-expression before 'int'
   42 |   vector<int> vis(n); vis[st]=1;
      |          ^~~
highway.cpp:42:23: error: 'vis' was not declared in this scope
   42 |   vector<int> vis(n); vis[st]=1;
      |                       ^~~
highway.cpp:43:3: error: 'queue' was not declared in this scope
   43 |   queue<int> q; q.push(st);
      |   ^~~~~
highway.cpp:43:9: error: expected primary-expression before 'int'
   43 |   queue<int> q; q.push(st);
      |         ^~~
highway.cpp:43:17: error: 'q' was not declared in this scope
   43 |   queue<int> q; q.push(st);
      |                 ^
highway.cpp:50:7: error: 'p' was not declared in this scope
   50 |       p[v]=i;
      |       ^
highway.cpp:51:7: error: 'e' was not declared in this scope
   51 |       e[i]={u,v};
      |       ^
highway.cpp:53:7: error: 'adj' was not declared in this scope
   53 |       adj[u].pb({v,i});
      |       ^~~
highway.cpp:56:3: error: 'z' was not declared in this scope
   56 |   z.clear();
      |   ^
highway.cpp:57:3: error: 'dfs' was not declared in this scope
   57 |   dfs(st,-1);
      |   ^~~
highway.cpp:59:5: error: expected ';' before 'S'
   59 |   ll S=ask(vector<int>(m,1));
      |     ^~
      |     ;
highway.cpp:62:12: error: expected primary-expression before 'int'
   62 |     vector<int> q(m);
      |            ^~~
highway.cpp:64:7: error: expected ';' before 'x'
   64 |     ll x=ask(q);
      |       ^~
      |       ;
highway.cpp:65:9: error: 'x' was not declared in this scope
   65 |     if (x==S) r=mid;
      |         ^
highway.cpp:65:12: error: 'S' was not declared in this scope
   65 |     if (x==S) r=mid;
      |            ^
highway.cpp:68:13: error: 'e' was not declared in this scope
   68 |   answer(st,e[z[r]].s);
      |             ^
highway.cpp:68:3: error: 'answer' was not declared in this scope
   68 |   answer(st,e[z[r]].s);
      |   ^~~~~~