Submission #151776

# Submission time Handle Problem Language Result Execution time Memory
151776 2019-09-04T16:23:35 Z phillip Teoretičar (COCI18_teoreticar) C++14
0 / 130
526 ms 28028 KB
#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

teoreticar.cpp: In function 'void dfs(int, int, int)':
teoreticar.cpp:12:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<v[x][id].size();i++)
                 ~^~~~~~~~~~~~~~~~
teoreticar.cpp: In function 'int main()':
teoreticar.cpp:51:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<p.size();i++)
                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 632 KB not colored properly
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 888 KB not colored properly
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 16376 KB not colored properly
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1292 KB not colored properly
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 526 ms 22780 KB not colored properly
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 427 ms 28028 KB not colored properly
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 381 ms 12256 KB not colored properly
2 Halted 0 ms 0 KB -