제출 #860423

#제출 시각아이디문제언어결과실행 시간메모리
860423jamkelTeoretičar (COCI18_teoreticar)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define st first #define nd second typedef long long ll; int l,r,m; int kol=1; int c=0; map<pair<int,int>,int>ma; int wynik[500000]; void dfs(int g,vector<vector<int>>&b,vector<pair<int,int>>&j,vector<pair<int,int>>&d, vector<bool>&czy,vector<bool>&czy2) { for(int i=0;i<b[g].size();i++) { if(min(g,b[g][i])==0) { if(czy2[max(g,b[g][i])]==true) { czy2[max(g,b[g][i])]=false; dfs(b[g][i],b,j,d,czy,czy2); c=(c+1)%2; } } else { if(czy[ma[{min(g,b[g][i]),max(g,b[g][i])}]]==true) { czy[ma[{min(g,b[g][i]),max(g,b[g][i])}]]=false; dfs(b[g][i],b,j,d,czy,czy2); if(c==0) { j.push_back({min(g,b[g][i]),max(g,b[g][i])}); } else { d.push_back({min(g,b[g][i]),max(g,b[g][i])}); } c=(c+1)%2; } } } } void q(vector<pair<int,int>>&a,vector<bool>&czy,vector<bool>&czy2) { vector<vector<int>>b(l+r+1); for(int i=0;i<a.size();i++) { b[a[i].nd].push_back(a[i].st); b[a[i].st].push_back(a[i].nd); } bool p=true; for(int i=0;i<a.size();i++) { if(b[a[i]].size()>1 or b[a[i]].size()>1) { p=false; break; } } if(p) { for(int i=0;i<a.size();i++) { wynik[ma[a[i]]]=kol; } kol++; return; } for(int i=1;i<b.size();i++) { if(b[i].size()%2==1) { b[i].push_back(0); b[0].push_back(i); czy2[i]=true;; } } for(int i=0;i<a.size();i++) { czy[ma[a[i]]]=true; } vector<pair<int,int>>j; vector<pair<int,int>>d; for(int i=0;i<l+r+1;i++) { dfs(i,b,j,d,czy,czy2); } q(j,czy,czy2); q(d,czy,czy2); } int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); cin>>l>>r>>m; vector<bool>czy(m); vector<bool>czy2(l+r+1); vector<pair<int,int>>a(m); for(int i=0;i<m;i--) { cin>>a[i].st>>a[i].nd; a[i].nd+=l; ma[a[i]]=i; } q(a,czy,czy2); cout<<kol-1<<endl; for(int i=0;i<m;i++) { cout<<wynik[i]<<'\n'; } }

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

teoreticar.cpp: In function 'void dfs(int, std::vector<std::vector<int> >&, std::vector<std::pair<int, int> >&, std::vector<std::pair<int, int> >&, std::vector<bool>&, std::vector<bool>&)':
teoreticar.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i=0;i<b[g].size();i++)
      |                 ~^~~~~~~~~~~~
teoreticar.cpp: In function 'void q(std::vector<std::pair<int, int> >&, std::vector<bool>&, std::vector<bool>&)':
teoreticar.cpp:47:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for(int i=0;i<a.size();i++)
      |                 ~^~~~~~~~~
teoreticar.cpp:53:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for(int i=0;i<a.size();i++)
      |                 ~^~~~~~~~~
teoreticar.cpp:55:13: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<int> >' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'})
   55 |         if(b[a[i]].size()>1 or b[a[i]].size()>1)
      |             ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from teoreticar.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::reference = std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::const_reference = const std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
teoreticar.cpp:55:33: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<int> >' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'})
   55 |         if(b[a[i]].size()>1 or b[a[i]].size()>1)
      |                                 ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from teoreticar.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::reference = std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::const_reference = const std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
teoreticar.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |         for(int i=0;i<a.size();i++)
      |                     ~^~~~~~~~~
teoreticar.cpp:70:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |      for(int i=1;i<b.size();i++)
      |                  ~^~~~~~~~~
teoreticar.cpp:79:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |     for(int i=0;i<a.size();i++)
      |                 ~^~~~~~~~~