제출 #984028

#제출 시각아이디문제언어결과실행 시간메모리
984028user736482Two Transportations (JOI19_transportations)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include<Azer.h> using namespace std; vector<int> answer,akliczby; int akwaga=1,akbit=-1,ak,state,rec,dist,ileod,n,prev; vector<bool>tym; bool odwiedzone[2000]; pair<int,int>pqtop; vector<pair<int,int>> sasiedzi[2000]; priority_queue<pair<int,int>>pq; void InitA(int N, int A, vector<int>U,vector<int>V,vector<int>C ){ odwiedzone[0]=1; n=N; for(int i=0;i<N;i++){ answer.push_back(9999999); } answer[0]=0; for(int i=0;i<A;i++){ sasiedzi[U[i]].push_back({C[i],V[i]}); sasiedzi[V[i]].push_back({C[i],U[i]}); } for(int i=0;i<(int)sasiedzi[0].size();i++){ pq.push(sasiedzi[0][i]); } pqtop=pq.top(); ak=pqtop.first; for(int i=0;i<9;i++){ SendA(ak%2); ak/=2; } } void ReceiveA(bool x){ if(state==0){ tym.push_back(x); akbit++; if(akbit==9){ akbit=0; rec=0; for(int i=8;i>=0;i--){ rec*=2; rec+=tym[i]; prev+=rec; } /*!!!!!!!!*/if(rec<pqtop.first){ state=1; dist=rec; } else{ prev+=pqtop.first; pq.pop(); ileod++; odwiedzone[pqtop.second]=1; answer[pqtop.second]=pqtop.first; for(int i=0;i<(int)sasiedzi[pqtop.second].size();i++){ pq.push({sasiedzi[pqtop.second][i].first+pqtop.first,sasiedzi[pqtop.second][i].second}); } ak=pqtop.second; for(int i=0;i<11;i++){ SendA(ak%2); ak/=2; } state=2; } } } if(state==1){ tym.push_back(x); akbit++; if(akbit==11){ akbit=0; rec=0; for(int i=10;i>=0;i--){ rec*=2; rec+=tym[i]; } ileod++; odwiedzone[rec]=1; answer[rec]=dist; for(int i=0;i<(int)sasiedzi[rec].size();i++){ pq.push({sasiedzi[rec][i].first+dist,sasiedzi[rec][i].second}); } } pqtop=pq.top(); while(odwiedzone[pqtop.second]){ pq.pop(); pqtop=pq.top(); } ak=pqtop.first-prev; state=0; for(int i=0;i<9;i++){ SendA(ak%2); ak/=2; } } if(state==2){ tym.push_back(x); akbit++; if(akbit==9){ akbit=0; rec=0; for(int i=8;i>=0;i--){ rec*=2; rec+=tym[i]; } pqtop=pq.top(); while(odwiedzone[pqtop.second]){ pq.pop(); pqtop=pq.top(); } ak=pqtop.first; for(int i=0;i<9;i++){ SendA(ak%2); ak/=2; } /*!!!!!!!!*/if(rec<pqtop.first){ state=1; dist=rec; prev+=rec; } else{ prev+=pqtop.first; pq.pop(); ileod++; odwiedzone[pqtop.second]=1; answer[pqtop.second]=pqtop.first; for(int i=0;i<(int)sasiedzi[pqtop.second].size();i++){ pq.push({sasiedzi[pqtop.second][i].first+pqtop.first,sasiedzi[pqtop.second][i].second}); } ak=pqtop.second-prev; for(int i=0;i<11;i++){ SendA(ak%2); ak/=2; } state=2; } } } } vector<int> Answer(){ return answer; }
#include<bits/stdc++.h> #include<Baijan.h> using namespace std; vector<int>answer; int odwiedzone[2000],ak,n,state,rec,dist,akbit,ileod=1,prev; vector<bool>tym; vector<pair<int,int>> sasiedzi[2000]; priority_queue<pair<int,int>>pq; pair<int,int>pqtop; void InitB(int N, int B, vector<int>U,vector<int>V,vector<int>C ){ set<pair<int,pair<int,int>>>krawedzie; int ak; for(int i=0;i<B;i++){ krawedzie.insert({C[i],{U[i],V[i]}}); } odwiedzone[0]=1; n=N; for(int i=0;i<N;i++){ answer.push_back(9999999); } answer[0]=0; for(int i=0;i<B;i++){ sasiedzi[U[i]].push_back({C[i],V[i]}); sasiedzi[V[i]].push_back({C[i],U[i]}); } for(int i=0;i<(int)sasiedzi[0].size();i++){ pq.push(sasiedzi[0][i]); } pqtop=pq.top(); ak=pqtop.first; for(int i=0;i<9;i++){ SendB(ak%2); ak/=2; } } void ReceiveB(bool y){ if(state==0){ tym.push_back(y); akbit++; if(akbit==9){ akbit=0; rec=0; for(int i=8;i>=0;i--){ rec*=2; rec+=tym[i]; } /*!!!!!!!!*/if(rec<=pqtop.first){ state=1; dist=rec; prev+=rec; } else{ pq.pop(); prev+=pqtop.first; ileod++; odwiedzone[pqtop.second]=1; answer[pqtop.second]=pqtop.first; for(int i=0;i<(int)sasiedzi[pqtop.second].size();i++){ pq.push({sasiedzi[pqtop.second][i].first+pqtop.first,sasiedzi[pqtop.second][i].second}); } ak=pqtop.second; for(int i=0;i<11;i++){ SendB(ak%2); ak/=2; } state=2; } } } if(state==1){ tym.push_back(y); akbit++; if(akbit==11){ akbit=0; rec=0; for(int i=10;i>=0;i--){ rec*=2; rec+=tym[i]; } ileod++; odwiedzone[rec]=1; answer[rec]=dist; for(int i=0;i<(int)sasiedzi[rec].size();i++){ pq.push({sasiedzi[rec][i].first+dist,sasiedzi[rec][i].second}); } } while(odwiedzone[pqtop.second]){ pq.pop(); pqtop=pq.top(); } pqtop=pq.top(); ak=pqtop.first-prev; state=0; for(int i=0;i<9;i++){ SendB(ak%2); ak/=2; } } if(state==2){ tym.push_back(y); akbit++; if(akbit==9){ akbit=0; rec=0; for(int i=8;i>=0;i--){ rec*=2; rec+=tym[i]; } while(odwiedzone[pqtop.second]){ pq.pop(); pqtop=pq.top(); } pqtop=pq.top(); ak=pqtop.first-prev; for(int i=0;i<9;i++){ SendB(ak%2); ak/=2; } /*!!!!!!!!*/if(rec<=pqtop.first){ state=1; dist=rec; prev+=rec; } else{ pq.pop(); ileod++; prev+=pqtop.first; odwiedzone[pqtop.second]=1; answer[pqtop.second]=pqtop.first; for(int i=0;i<(int)sasiedzi[pqtop.second].size();i++){ pq.push({sasiedzi[pqtop.second][i].first+pqtop.first,sasiedzi[pqtop.second][i].second}); } ak=pqtop.second; for(int i=0;i<11;i++){ SendB(ak%2); ak/=2; } state=2; } } } }

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

Azer.cpp: In function 'void ReceiveA(bool)':
Azer.cpp:42:17: error: reference to 'prev' is ambiguous
   42 |                 prev+=rec;
      |                 ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Azer.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Azer.cpp:5:49: note:                 'int prev'
    5 | int akwaga=1,akbit=-1,ak,state,rec,dist,ileod,n,prev;
      |                                                 ^~~~
Azer.cpp:49:17: error: reference to 'prev' is ambiguous
   49 |                 prev+=pqtop.first;
      |                 ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Azer.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Azer.cpp:5:49: note:                 'int prev'
    5 | int akwaga=1,akbit=-1,ak,state,rec,dist,ileod,n,prev;
      |                                                 ^~~~
Azer.cpp:88:24: error: reference to 'prev' is ambiguous
   88 |         ak=pqtop.first-prev;
      |                        ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Azer.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Azer.cpp:5:49: note:                 'int prev'
    5 | int akwaga=1,akbit=-1,ak,state,rec,dist,ileod,n,prev;
      |                                                 ^~~~
Azer.cpp:119:17: error: reference to 'prev' is ambiguous
  119 |                 prev+=rec;
      |                 ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Azer.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Azer.cpp:5:49: note:                 'int prev'
    5 | int akwaga=1,akbit=-1,ak,state,rec,dist,ileod,n,prev;
      |                                                 ^~~~
Azer.cpp:122:17: error: reference to 'prev' is ambiguous
  122 |                 prev+=pqtop.first;
      |                 ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Azer.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Azer.cpp:5:49: note:                 'int prev'
    5 | int akwaga=1,akbit=-1,ak,state,rec,dist,ileod,n,prev;
      |                                                 ^~~~
Azer.cpp:130:33: error: reference to 'prev' is ambiguous
  130 |                 ak=pqtop.second-prev;
      |                                 ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Azer.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Azer.cpp:5:49: note:                 'int prev'
    5 | int akwaga=1,akbit=-1,ak,state,rec,dist,ileod,n,prev;
      |                                                 ^~~~

Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:52:17: error: reference to 'prev' is ambiguous
   52 |                 prev+=rec;
      |                 ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Baijan.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Baijan.cpp:6:56: note:                 'int prev'
    6 | int odwiedzone[2000],ak,n,state,rec,dist,akbit,ileod=1,prev;
      |                                                        ^~~~
Baijan.cpp:56:17: error: reference to 'prev' is ambiguous
   56 |                 prev+=pqtop.first;
      |                 ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Baijan.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Baijan.cpp:6:56: note:                 'int prev'
    6 | int odwiedzone[2000],ak,n,state,rec,dist,akbit,ileod=1,prev;
      |                                                        ^~~~
Baijan.cpp:94:24: error: reference to 'prev' is ambiguous
   94 |         ak=pqtop.first-prev;
      |                        ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Baijan.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Baijan.cpp:6:56: note:                 'int prev'
    6 | int odwiedzone[2000],ak,n,state,rec,dist,akbit,ileod=1,prev;
      |                                                        ^~~~
Baijan.cpp:117:28: error: reference to 'prev' is ambiguous
  117 |             ak=pqtop.first-prev;
      |                            ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Baijan.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Baijan.cpp:6:56: note:                 'int prev'
    6 | int odwiedzone[2000],ak,n,state,rec,dist,akbit,ileod=1,prev;
      |                                                        ^~~~
Baijan.cpp:125:17: error: reference to 'prev' is ambiguous
  125 |                 prev+=rec;
      |                 ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Baijan.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Baijan.cpp:6:56: note:                 'int prev'
    6 | int odwiedzone[2000],ak,n,state,rec,dist,akbit,ileod=1,prev;
      |                                                        ^~~~
Baijan.cpp:130:17: error: reference to 'prev' is ambiguous
  130 |                 prev+=pqtop.first;
      |                 ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Baijan.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Baijan.cpp:6:56: note:                 'int prev'
    6 | int odwiedzone[2000],ak,n,state,rec,dist,akbit,ileod=1,prev;
      |                                                        ^~~~