Submission #76069

# Submission time Handle Problem Language Result Execution time Memory
76069 2018-09-12T03:07:57 Z thebes Party (POI11_imp) C++14
0 / 100
3000 ms 66560 KB
#include <bits/stdc++.h>
using namespace std;

const int MN = 3003;
int p[MN], n, sz, m, i, x, y, deg[MN];
vector<int> adj[MN];

int main(){
    for(scanf("%d%d",&n,&m),i=1;i<=m;i++){
        scanf("%d%d",&x,&y);
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for(i=1;i<=n;i++){
        if(adj[i].size()>=n/3-1){
            p[++sz] = i;
        }
    }
    while(1){
        random_shuffle(p+1,p+sz+1);
        memset(deg, 0, sizeof(deg));
        for(i=1;i<=n/3;i++){
            for(auto v : adj[p[i]])
                deg[v] ++;
        }
        bool fnd = 1;
        for(i=1;i<=n/3;i++){
            if(deg[p[i]] != n/3-1){
                fnd = 0;
                break;
            }
        }
        if(fnd){
            for(i=1;i<=n/3;i++)
                printf("%d ",p[i]);
            return 0;
        }
    }
}

Compilation message

imp.cpp: In function 'int main()':
imp.cpp:15:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(adj[i].size()>=n/3-1){
            ~~~~~~~~~~~~~^~~~~~~
imp.cpp:9:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(scanf("%d%d",&n,&m),i=1;i<=m;i++){
         ~~~~~~~~~~~~~~~~~~~^~~~
imp.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&x,&y);
         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 516 KB Output is correct
3 Correct 2999 ms 556 KB Output is correct
4 Correct 2192 ms 684 KB Output is correct
5 Execution timed out 3032 ms 684 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 3049 ms 912 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3042 ms 1824 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3009 ms 3132 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3026 ms 7508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3012 ms 21908 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3038 ms 37500 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3044 ms 55820 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3045 ms 66560 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3032 ms 66560 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3015 ms 66560 KB Time limit exceeded
2 Halted 0 ms 0 KB -