제출 #858353

#제출 시각아이디문제언어결과실행 시간메모리
858353jamkelTeoretičar (COCI18_teoreticar)C++14
0 / 130
838 ms28604 KiB
#include <bits/stdc++.h> using namespace std; #define st first #define nd second typedef long long ll; bool dfs(vector<vector<pair<int,bool>>>&a,vector<vector<pair<int,bool>>>&b, vector<bool>&odwiedzone,bool czy,int co) { int f=0; if(czy) { f+=a.size(); } if(odwiedzone[co+f]) { return false; } odwiedzone[co+f]=true; if(czy) { for(int i=0;i<b[co].size();i++) { if(b[co][i].nd==true) { if(dfs(a,b,odwiedzone,false,b[co][i].st)) { b[co][i].nd=false; for(int o=0;o<a[b[co][i].st].size();o++) { if(a[b[co][i].st][o].st==co) { a[b[co][i].st][o].nd=false; break; } } return true; } return false; } } return true; } else { for(int i=0;i<a[co].size();i++) { if(a[co][i].nd==false) { if(dfs(a,b,odwiedzone,true,a[co][i].st)) { a[co][i].nd=true; for(int o=0;o<b[a[co][i].st].size();o++) { if(b[a[co][i].st][o].st==co) { b[a[co][i].st][o].nd=true; break; } } return true; } } }return false; } } int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int l,r,m; cin>>l>>r>>m; vector<vector<pair<int,bool>>>a(l); vector<bool>w(l); vector<vector<pair<int,bool>>>b(r); vector<int>q(l); srand((unsigned) time(NULL)); for(int i=0;i<l;i++) { q[i]=i; } random_shuffle(q.begin(),q.end()); for(int i=0;i<m;i++) { int x,y; cin>>x>>y; a[x].push_back({y,false}); b[y].push_back({x,false}); } bool ok=true; int ile=0; while(ok) { ok=false; vector<bool>odwiedzone(l+r); for(int i=0;i<l;i++) { if(!w[q[i]]) { if(dfs(a,b,odwiedzone,false,q[i])) { ok=true; ile++; w[q[i]]=true; } } } } cout<<ile<<endl; for(int i=0;i<l;i++) { for(int o=0;o<a[i].size();o++) { if(a[i][o].nd==true) { cout<<i<<" "<<a[i][o].st<<endl; } } } }

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

teoreticar.cpp: In function 'bool dfs(std::vector<std::vector<std::pair<int, bool> > >&, std::vector<std::vector<std::pair<int, bool> > >&, std::vector<bool>&, bool, int)':
teoreticar.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         for(int i=0;i<b[co].size();i++)
      |                     ~^~~~~~~~~~~~~
teoreticar.cpp:27:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |                     for(int o=0;o<a[b[co][i].st].size();o++)
      |                                 ~^~~~~~~~~~~~~~~~~~~~~~
teoreticar.cpp:45:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for(int i=0;i<a[co].size();i++)
      |                     ~^~~~~~~~~~~~~
teoreticar.cpp:52:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |                     for(int o=0;o<b[a[co][i].st].size();o++)
      |                                 ~^~~~~~~~~~~~~~~~~~~~~~
teoreticar.cpp: In function 'int main()':
teoreticar.cpp:113:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  113 |         for(int o=0;o<a[i].size();o++)
      |                     ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...