# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
234793 | 2020-05-25T16:15:10 Z | medk | 길고양이 (JOI20_stray) | C++14 | 컴파일 오류 |
0 ms | 0 KB |
#include <bits/stdc++.h> #include "Anthony.h" #define pb push_back #define eb emplace_back using namespace std; int n,m; vector<vector<pair<int,int>>> g; vector<int> seq={0,1,0,0,1,1}; vector<int> Mark1(); vector<int> Mark2(); vector<int> Mark(int N, int M, int A, int B, vector<int> U, vector<int> V){ n=N, m=M; g.resize(n); for(int i=0;i<m;i++){ g[U[i]].eb(V[i],i); g[V[i]].eb(U[i],i); } if(A>=3) return Mark1(); return Mark2(); } vector<int> Mark1(){ vector<int> dpth(n); vector<bool> vis(n); vector<int> ans(m); queue<int> bfs; bfs.push(0); dpth[0]=0; vis[0]=1; while(!bfs.empty()){ int u=bfs.front(); bfs.pop(); for(auto p:g[u]){ int v=p.first, e=p.second; if(!vis[v]){ vis[v]=1; bfs.push(v); dpth[v]=dpth[u]+1; ans[e]=dpth[v]%3; } else{ if(dpth[v]==dpth[u]) ans[e]=(dpth[v]+1)%3; else ans[e]=max(dpth[v],dpth[u])%3; } } } return ans; } vector<int> Mark2(){ vector<bool> vis(n); vector<int> ans(m); queue<pair<int,int>> bfs; bfs.push({0,0}); vis[0]=1; while(!bfs.empty()){ int u=bfs.front().first, col=bfs.front().second; bfs.pop(); for(auto p:g[u]){ int v=p.first, e=p.second; if(vis[v]) continue; vis[v]=1; if(g[u].size()<=2){ ans[e]=(col+1)%6; bfs.push({v,ans[e]}); } else{ ans[e]=seq[col]^1; bfs.push({v,ans[e]}); } } } for(int i=0;i<m;i++) ans[i]=seq[ans[i]]; return ans; }
#include <bits/stdc++.h> #include "Catherine.h" #define pb push_back #define x first #define y second using namespace std; int a; int prev=-1; bool trying=true; int cnt=0,revrem=0; vector<int> sq; void Init(int A, int B){ a=A; } int Move1(vector<int> arr); int Move2(vector<int> arr); int Move(vector<int> arr){ if(a>=3) return Move1(arr); return Move2(arr); } int Move1(vector<int> arr){ set<int> st={0,1,2}; for(int i=0;i<3;i++) if(arr[i]==0) st.erase(i); if(st.size()==1) return *st.begin(); if(*next(st.begin())-*st.begin()==1) return *st.begin(); return 2; } int Move2(vector<int> arr){ if(trying){ cnt++; if(cnt==1){ int sum=arr[0]+arr[1]; if(sum>2){ trying=false; if(arr[0]==1){ prev=0; return 0; } prev=1; return 1; } else{ for(int i=0;i<arr[0];i++) sq.pb(0); for(int i=0;i<arr[1];i++) sq.pb(1); prev=sq.back(); if(sum==1) trying=false; return prev; } } else{ int sum=arr[0]+arr[1]; if(sum>=2){ trying=false; if(arr[prev]==0){ prev=sq.back(); sq.pop_back(); revrem=cnt-2; return -1; } else{ prev^=1; return prev; } } else{ sq.pb(arr[0]==0); if(cnt<4){ prev=sq.back(); return prev; } else{ trying=false; if(sq=={0,1,0,0,1} || sq=={1,0,0,1,1} || sq=={0,0,1,1,0} || sq=={0,1,1,0,1} || sq=={1,1,0,1,0} || sq=={1,0,1,0,0}){ sq.pop_back(); prev=sq.back(); revrem=2; return -1; } else{ prev=sq.back(); return prev; } } } } } if(revrem>0){ revrem--; prev=sq.back(); sq.pop_back(); return -1; } if(arr[0]+arr[1]==1){ prev=(arr[0]==0); return prev; } prev^=1; return prev; }
Compilation message
Catherine.cpp: In function 'int Move2(std::vector<int>)': Catherine.cpp:44:6: error: reference to 'prev' is ambiguous prev=0; ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:47:5: error: reference to 'prev' is ambiguous prev=1; ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:53:5: error: reference to 'prev' is ambiguous prev=sq.back(); ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:55:12: error: reference to 'prev' is ambiguous return prev; ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:62:12: error: reference to 'prev' is ambiguous if(arr[prev]==0){ ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:63:6: error: reference to 'prev' is ambiguous prev=sq.back(); ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:69:6: error: reference to 'prev' is ambiguous prev^=1; ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:70:13: error: reference to 'prev' is ambiguous return prev; ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:76:6: error: reference to 'prev' is ambiguous prev=sq.back(); ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:77:13: error: reference to 'prev' is ambiguous return prev; ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:81:13: error: expected primary-expression before '{' token if(sq=={0,1,0,0,1} || sq=={1,0,0,1,1} || sq=={0,0,1,1,0} || sq=={0,1,1,0,1} || sq=={1,1,0,1,0} || sq=={1,0,1,0,0}){ ^ Catherine.cpp:81:13: error: expected ')' before '{' token Catherine.cpp:83:7: error: reference to 'prev' is ambiguous prev=sq.back(); ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:88:7: error: reference to 'prev' is ambiguous prev=sq.back(); ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:89:14: error: reference to 'prev' is ambiguous return prev; ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:97:3: error: reference to 'prev' is ambiguous prev=sq.back(); ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:102:3: error: reference to 'prev' is ambiguous prev=(arr[0]==0); ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:103:10: error: reference to 'prev' is ambiguous return prev; ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:105:2: error: reference to 'prev' is ambiguous prev^=1; ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~ Catherine.cpp:106:9: error: reference to 'prev' is ambiguous return prev; ^~~~ Catherine.cpp:11:5: note: candidates are: int prev int prev=-1; ^~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0, from /usr/include/c++/7/bits/char_traits.h:39, from /usr/include/c++/7/ios:40, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /usr/include/c++/7/complex:45, from /usr/include/c++/7/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Catherine.cpp:1: /usr/include/c++/7/bits/stl_iterator_base_funcs.h:220:5: note: template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) prev(_BidirectionalIterator __x, typename ^~~~