# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
151776 | phillip | Teoretičar (COCI18_teoreticar) | C++14 | 526 ms | 28028 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n,l,r,mx;
vector<int>v[5009][2];
vector<pair<int,int> >p;
int c[5009][5009];
bool vis[5009][2];
void dfs(int x,int id,int sc)
{
sc%=mx;
for(int i=0;i<v[x][id].size();i++)
{
int y=v[x][id][i];
if(vis[y][1-id])continue;
if(id==0)c[x][y]=sc;
else c[y][x]=sc;
vis[y][1-id]=1;
dfs(y,1-id,sc+1);
sc++;
sc%=mx;
}
}
int a[2];
int main()
{
cin>>a[0]>>a[1]>>n;
for(int i=0;i<n;i++)
{
int x,y;
cin>>x>>y;
x--;y--;
v[x][0].push_back(y);
v[y][1].push_back(x);
p.push_back({x,y});
}
for(int j=0;j<2;j++)
for(int i=0;i<a[j];i++)
{
int x=v[i][j].size();
mx=max(mx,x);
}
for(int j=0;j<2;j++)
for(int i=0;i<a[j];i++)
{
if(vis[i][j])continue;
vis[i][j]=1;
dfs(i,j,0);
}
cout<<mx<<"\n";
for(int i=0;i<p.size();i++)
{
cout<<c[p[i].first][p[i].second]+1<<"\n";
}
}
Compilation message (stderr)
# | 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... |