이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |