Submission #472340

# Submission time Handle Problem Language Result Execution time Memory
472340 2021-09-13T11:59:59 Z SaraMostafa Teoretičar (COCI18_teoreticar) C++14
13 / 130
12000 ms 262148 KB
#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
1 Incorrect 1 ms 332 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 2416 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 46 ms 2228 KB Output is correct
2 Incorrect 19 ms 2316 KB too many colors
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4085 ms 141288 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3827 ms 141240 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 12024 ms 93844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 12101 ms 145984 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2007 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 12087 ms 87640 KB Time limit exceeded
2 Halted 0 ms 0 KB -