Submission #472359

# Submission time Handle Problem Language Result Execution time Memory
472359 2021-09-13T12:18:55 Z SaraMostafa Teoretičar (COCI18_teoreticar) C++14
0 / 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,set<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].insert(b);
            mp[b].insert(a);
            ed[ {a,b}]=i;
            ed[ {b,a}]=i;
        }
        ll c=1,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 Incorrect 1 ms 332 KB too many colors
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 2884 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 61 ms 2500 KB Output is correct
2 Correct 21 ms 2612 KB Output is correct
3 Correct 19 ms 2936 KB Output is correct
4 Incorrect 22 ms 2332 KB too many colors
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4369 ms 165892 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4222 ms 165740 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 12070 ms 128308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 12075 ms 172012 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2412 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 12082 ms 113512 KB Time limit exceeded
2 Halted 0 ms 0 KB -