제출 #472340

#제출 시각아이디문제언어결과실행 시간메모리
472340SaraMostafaTeoretičar (COCI18_teoreticar)C++14
13 / 130
12101 ms262148 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) { for(auto j:i.second) { c=1; 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...