제출 #858376

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

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

teoreticar.cpp: In function 'bool dfs(std::vector<std::vector<std::pair<long long int, long long int> > >&, std::vector<std::vector<std::pair<long long int, long long int> > >&, std::vector<bool>&, bool, ll)':
teoreticar.cpp:21:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for(ll i=0;i<b[co].size();i++)
      |                    ~^~~~~~~~~~~~~
teoreticar.cpp:28:33: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |                     for(ll o=0;o<a[b[co][i].st].size();o++)
      |                                ~^~~~~~~~~~~~~~~~~~~~~~
teoreticar.cpp:46:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         for(ll i=0;i<a[co].size();i++)
      |                    ~^~~~~~~~~~~~~
teoreticar.cpp:53:33: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |                     for(ll o=0;o<b[a[co][i].st].size();o++)
      |                                ~^~~~~~~~~~~~~~~~~~~~~~
teoreticar.cpp: In function 'int main()':
teoreticar.cpp:120:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::vector<std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  120 |     for(ll i=0;i<a.size();i++)
      |                ~^~~~~~~~~
teoreticar.cpp:122:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  122 |         for(ll j=0;j<a[i].size();j++)
      |                    ~^~~~~~~~~~~~
#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...