Submission #290410

#TimeUsernameProblemLanguageResultExecution timeMemory
290410TadijaSebezTwo Transportations (JOI19_transportations)C++14
Compilation error
0 ms0 KiB
#include "Azer.h" #include <bits/stdc++.h> using namespace std; #define vi vector<int> #define pii pair<int,int> #define pb push_back namespace{ const int N=2050; const int L=20; const int inf=(1<<20)-1; vector<pii> E[N]; int dist[N],n; bool was[N]; void Upd(int x){ was[x]=1; for(auto e:E[x]){ int v,w;tie(v,w)=e; if(!was[v]){ dist[v]=min(dist[v],dist[x]+w); } } } int cnt,X,Y,node,D; int wait; void Send(){ Y=inf; bool ok=0; for(int i=0;i<n;i++)if(!was[i]){ ok=1; if(Y>dist[i]){ Y=dist[i]; node=i; } } if(!ok)return; for(int i=L-1;~i;i--)SendA(Y>>i&1); wait=1; } } void InitA(int n,int a,vi u,vi v,vi w){ ::n=n; for(int i=0;i<a;i++)E[u[i]].pb({v[i],w[i]}),E[v[i]].pb({u[i],w[i]}); for(int i=1;i<n;i++)dist[i]=inf; Upd(0); Send(); } void ReceiveA(bool x){ X=X*2+x; cnt++; if(wait==1){ if(cnt==L){ if(Y<=X){ for(int i=10;~i;i--)SendA(node>>i&1); Upd(node); Send(); cnt=0; X=0; }else{ D=X; wait=2; cnt=0; X=0; } } }else if(wait==2){ if(cnt==11){ dist[X]=D; Upd(X); Send(); cnt=0; X=0; } } } vi Answer(){ vi ans; for(int i=0;i<n;i++)ans.pb(dist[i]); return ans; }
#include "Baijan.h" #include <bits/stdc++.h> using namespace std; #define vi vector<int> #define pii pair<int,int> #define pb push_back namespace{ const int N=2050; const int L=20; const int inf=(1<<20)-1; vector<pii> E[N]; int dist[N],n; bool was[N]; void Upd(int x){ was[x]=1; for(auto e:E[x]){ int v,w;tie(v,w)=e; if(!was[v]){ dist[v]=min(dist[v],dist[x]+w); } } } int cnt,X,Y,node,D; int wait; void Send(){ Y=inf; bool ok=0; for(int i=0;i<n;i++)if(!was[i]){ ok=1; if(Y>dist[i]){ Y=dist[i]; node=i; } } if(!ok)return; for(int i=L-1;~i;i--)SendB(Y>>i&1); wait=1; } } void InitB(int n,int b,vi u,vi v,vi w){ ::n=n; for(int i=0;i<b;i++)E[u[i]].pb({v[i],w[i]}),E[v[i]].pb({u[i],w[i]}); for(int i=1;i<n;i++)dist[i]=inf; Upd(0); Send(); } void ReceiveB(bool y){ X=X*2+y; cnt++; if(wait==1){ if(cnt==L){ if(Y<=X){ for(int i=10;~i;i--)SendB(node>>i&1); Upd(node); Send(); cnt=0; X=0; }else{ D=X; wait=2; cnt=0; X=0; } } }else if(wait==2){ if(cnt==11){ dist[X]=D; Upd(X); Send(); cnt=0; X=0; } } }

Compilation message (stderr)

Azer.cpp: In function 'void ReceiveA(bool)':
Azer.cpp:53:5: error: reference to 'wait' is ambiguous
   53 |  if(wait==1){
      |     ^~~~
Azer.cpp:25:6: note: candidates are: 'int {anonymous}::wait'
   25 |  int wait;
      |      ^~~~
In file included from /usr/include/stdlib.h:42,
                 from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from Azer.cpp:2:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:66:7: note:                 'union wait'
   66 | union wait
      |       ^~~~
Azer.cpp:63:5: error: reference to 'wait' is ambiguous
   63 |     wait=2;
      |     ^~~~
Azer.cpp:25:6: note: candidates are: 'int {anonymous}::wait'
   25 |  int wait;
      |      ^~~~
In file included from /usr/include/stdlib.h:42,
                 from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from Azer.cpp:2:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:66:7: note:                 'union wait'
   66 | union wait
      |       ^~~~
Azer.cpp:68:11: error: reference to 'wait' is ambiguous
   68 |  }else if(wait==2){
      |           ^~~~
Azer.cpp:25:6: note: candidates are: 'int {anonymous}::wait'
   25 |  int wait;
      |      ^~~~
In file included from /usr/include/stdlib.h:42,
                 from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from Azer.cpp:2:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:66:7: note:                 'union wait'
   66 | union wait
      |       ^~~~

Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:53:5: error: reference to 'wait' is ambiguous
   53 |  if(wait==1){
      |     ^~~~
Baijan.cpp:25:6: note: candidates are: 'int {anonymous}::wait'
   25 |  int wait;
      |      ^~~~
In file included from /usr/include/stdlib.h:42,
                 from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from Baijan.cpp:2:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:66:7: note:                 'union wait'
   66 | union wait
      |       ^~~~
Baijan.cpp:63:5: error: reference to 'wait' is ambiguous
   63 |     wait=2;
      |     ^~~~
Baijan.cpp:25:6: note: candidates are: 'int {anonymous}::wait'
   25 |  int wait;
      |      ^~~~
In file included from /usr/include/stdlib.h:42,
                 from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from Baijan.cpp:2:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:66:7: note:                 'union wait'
   66 | union wait
      |       ^~~~
Baijan.cpp:68:11: error: reference to 'wait' is ambiguous
   68 |  }else if(wait==2){
      |           ^~~~
Baijan.cpp:25:6: note: candidates are: 'int {anonymous}::wait'
   25 |  int wait;
      |      ^~~~
In file included from /usr/include/stdlib.h:42,
                 from /usr/include/c++/9/bits/std_abs.h:38,
                 from /usr/include/c++/9/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from Baijan.cpp:2:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:66:7: note:                 'union wait'
   66 | union wait
      |       ^~~~