제출 #916607

#제출 시각아이디문제언어결과실행 시간메모리
916607winter0101Two Transportations (JOI19_transportations)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define all(fl) fl.begin(),fl.end() #define pb push_back #define fi first #define se second #define for1(i,j,k) for(int i=j;i<=k;i++) #define for2(i,j,k) for(int i=j;i>=k;i--) #define for3(i,j,k,l) for(int i=j;i<=k;i+=l) #define lb lower_bound #define ub upper_bound #define sz(a) (int)a.size() #define pii pair<int,int> #define pli pair<long long,int> #define gcd __gcd #define lcm(x,y) x*y/__gcd(x,y) namespace { int N; int reada=0,hra=0,nra=0,vertice=0,value=0,lst=0,dem=0,va=0; } // namespace const int maxn=2e3+9; const int inf=5e7; vector<pii>a[maxn]; int d[maxn]; bool vis[maxn]; void dit(){ int diff=value-lst; for1(i,0,8){ SendA(diff>>i&1); } reada=0; hra=0; nra=9; } void update(){ if (dem==N)return; int nw=-1; for1(i,0,N-1){ if (vis[i])continue; if (nw==-1)nw=i; if (d[nw]>d[i])nw=i; } reada=0; hra=0; nra=0; vertice=nw,value=d[nw]; if (value==inf)value=lst+(1<<9)-1; dem++; dit(); } void InitA(int N, int A, std::vector<int> U, std::vector<int> V,std::vector<int> C) { ::N=N; for1(i,0,N-1){ d[i]=inf; } for1(i,0,A-1){ a[U[i]].pb({V[i],C[i]}),a[V[i]].pb({U[i],C[i]}); } d[0]=0; update(); } void ReceiveA(bool x) { reada|=(x<<hra); hra++; if (hra==nra){ if (hra==9){ if (reada<value-lst){//need read vertice of b va=reada; reada=0; hra=0; nra=11; } else {//don't need nra=0; hra=0; for1(i,0,10)SendA(vertice>>i&1); vis[vertice]=1; lst=d[vertice]; for (auto v:a[vertice]){ if (d[vertice]+v.se<d[v.fi]){ d[v.fi]=d[vertice]+v.se; } } update(); return; } } else { //cerr<<vertice<<" "<<reada<<" "<<va<<" "<<lst<<'\n'; d[reada]=va+lst; vertice=reada; vis[vertice]=1; lst=d[vertice]; for (auto v:a[vertice]){ if (d[vertice]+v.se<d[v.fi]){ d[v.fi]=d[vertice]+v.se; } } reada=0; nra=0; hra=0; update(); return; } } } std::vector<int> Answer() { std::vector<int> ans(N); for (int k = 0; k < N; ++k) { ans[k] = d[k]; } return ans; }
#include<bits/stdc++.h> using namespace std; #define all(fl) fl.begin(),fl.end() #define pb push_back #define fi first #define se second #define for1(i,j,k) for(int i=j;i<=k;i++) #define for2(i,j,k) for(int i=j;i>=k;i--) #define for3(i,j,k,l) for(int i=j;i<=k;i+=l) #define lb lower_bound #define ub upper_bound #define sz(a) (int)a.size() #define pii pair<int,int> #define pli pair<long long,int> #define gcd __gcd #define lcm(x,y) x*y/__gcd(x,y) const int maxn=2e3+9; const int inf=5e6+9; namespace { int n; int readb=0,hrb=0,nrb=0,ver=0,vl=0,last=0,vb=0,demb=0; } // namespace vector<pii>g[maxn]; int dis[maxn]; bool visit[maxn]; void du(){ int diff=vl-last; //cerr<<diff<<'\n'; for1(i,0,8){ SendB(diff>>i&1); } } void add(){ if (demb==n)return; demb++; int nw=-1; for1(i,0,n-1){ if (visit[i])continue; if (nw==-1)nw=i; if (dis[nw]>dis[i])nw=i; } ver=nw; vl=dis[nw]; if (vl==inf)vl=last+(1<<9)-1; //if (ver==2)cout<<vl<<" "<<last<<'\n'; } void InitB(int N, int B, std::vector<int> S, std::vector<int> T,std::vector<int> D) { n=N; for1(i,0,n-1)dis[i]=inf; for1(i,0,B-1){ g[S[i]].pb({T[i],D[i]}); g[T[i]].pb({S[i],D[i]}); } dis[0]=0; readb=0; nrb=9; hrb=0; } void ReceiveB(bool y) { readb|=(y<<hrb); hrb++; if (hrb==nrb){ if (nrb==9){ add(); //cerr<<readb<<'\n'; du(); if (readb<=vl-last){ vb=readb; readb=0; nrb=11; hrb=0; } else { for1(i,0,10)SendB(ver>>i&1); //cerr<<ver<<" "<<dis[ver]<<'\n'; visit[ver]=1; last=dis[ver]; for (auto v:g[ver]){ if (dis[v.fi]>dis[ver]+v.se){ dis[v.fi]=dis[ver]+v.se; } } readb=0; nrb=9; hrb=0; return; } } else { //cerr<<readb<<'\n'; dis[readb]=vb+last; ver=readb; last=dis[ver]; visit[ver]=1; for (auto v:g[ver]){ if (dis[v.fi]>dis[ver]+v.se){ dis[v.fi]=dis[ver]+v.se; } } readb=0; nrb=9; hrb=0; return; } } }

컴파일 시 표준 에러 (stderr) 메시지

Azer.cpp: In function 'void dit()':
Azer.cpp:32:1: error: 'SendA' was not declared in this scope
   32 | SendA(diff>>i&1);
      | ^~~~~
Azer.cpp: In function 'void ReceiveA(bool)':
Azer.cpp:80:17: error: 'SendA' was not declared in this scope
   80 |     for1(i,0,10)SendA(vertice>>i&1);
      |                 ^~~~~

Baijan.cpp: In function 'void du()':
Baijan.cpp:30:1: error: 'SendB' was not declared in this scope
   30 | SendB(diff>>i&1);
      | ^~~~~
Baijan.cpp: In function 'void add()':
Baijan.cpp:38:5: error: reference to 'visit' is ambiguous
   38 | if (visit[i])continue;
      |     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from Baijan.cpp:1:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
Baijan.cpp:25:6: note:                 'bool visit [2009]'
   25 | bool visit[maxn];
      |      ^~~~~
Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:75:17: error: 'SendB' was not declared in this scope
   75 |     for1(i,0,10)SendB(ver>>i&1);
      |                 ^~~~~
Baijan.cpp:77:5: error: reference to 'visit' is ambiguous
   77 |     visit[ver]=1;
      |     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from Baijan.cpp:1:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
Baijan.cpp:25:6: note:                 'bool visit [2009]'
   25 | bool visit[maxn];
      |      ^~~~~
Baijan.cpp:95:5: error: reference to 'visit' is ambiguous
   95 |     visit[ver]=1;
      |     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:133,
                 from Baijan.cpp:1:
/usr/include/c++/10/variant:1700:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr decltype(auto) std::visit(_Visitor&&, _Variants&& ...)'
 1700 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
Baijan.cpp:25:6: note:                 'bool visit [2009]'
   25 | bool visit[maxn];
      |      ^~~~~