Submission #472329

#TimeUsernameProblemLanguageResultExecution timeMemory
472329SaraMostafaTeoretičar (COCI18_teoreticar)C++14
0 / 130
12028 ms182292 KiB
#include <bits/stdc++.h> #include<unordered_map> using namespace std; #define ll long long #define endl "\n" #define Sara ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); const long long mod=998244353; const double PI=acos(-1); int main() { //freopen("input.in","r",stdin); Sara ll l,r,e; cin>>l>>r>>e; map<ll,vector<ll>>mp; map<pair<ll,ll>,ll>ed; map<ll,ll>col; for(int i=0; i<e; i++) { ll a,b; cin>>a>>b; b*=-1; mp[a].push_back(b); mp[b].push_back(a); ed[ {a,b}]=i; ed[ {b,a}]=i; } ll c=0,mx=0; map<pair<ll,ll>,bool>vs; for(auto i:mp) { c=1; for(auto j:i.second) { if(col[ed[{i.first,j}]]) continue; while(vs[{j,c}] || vs[{i.first,c}]){ c++; } col[ed[ {i.first,j}]]=c; col[ed[ {j,i.first}]]=c; vs[{i.first,c}]=1; vs[{j,c}]=1; mx=max(mx,c); } } cout<<mx<<endl; for(int i=0;i<e;i++) cout<<col[i]<<endl; return 0; }
#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...