Submission #472329

# Submission time Handle Problem Language Result Execution time Memory
472329 2021-09-13T11:50:19 Z SaraMostafa Teoretičar (COCI18_teoreticar) C++14
0 / 130
12000 ms 182292 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)
    {

        c=1;
        for(auto j:i.second)
        {

            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 Incorrect 1 ms 332 KB too many colors
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 2576 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 2268 KB Output is correct
2 Incorrect 23 ms 2252 KB too many colors
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4112 ms 144408 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4139 ms 144428 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 12028 ms 104204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5477 ms 182292 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4370 ms 160364 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5098 ms 136604 KB too many colors
2 Halted 0 ms 0 KB -