Submission #814629

# Submission time Handle Problem Language Result Execution time Memory
814629 2023-08-08T08:38:16 Z t6twotwo Newspapers (CEOI21_newspapers) C++17
12 / 100
163 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FFOR(i,a,b,c) for(int i=(a);(c)>0?i<=(b):i>=(b);i+=(c))
#define FOOR(i,a,b) FFOR(i,a,b-1,1)
#define ROOF(i,a,b) FFOR(i,b-1,a,-1)
#define FOR(i,n) FOOR(i,0,n)
#define ROF(i,n) ROOF(i,0,n)
#define FORR(x,v) for(auto &x:v)
#define all(v) (v).begin(),(v).end()
#define lla(v) (v).rbegin(),(v).rend()
#define sz(v) (int)((v).size())
#define vc vector
#define pb push_back
#define ppb pop_back
#define bk back()
#define fr front()
#define pp pop()
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define bg begin()
#define en end()
#define em empty()
#define f first
#define s second
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin>>N>>M;
    vc<int> adj(N);
    FOR(i,M){
        int x,y;
        cin>>x>>y;
        x--,y--;
        adj[x]+=1<<y;
        adj[y]+=1<<x;
    }
    if(M!=N-1){
        cout<<"NO\n";
        return 0;
    }
    vector<int> f(1<<N,-1),g(1<<N);
    queue<int> q;
    f[(1<<N)-1]=0;
    q.push((1<<N)-1);
    while(!q.em){
        int m=q.fr;q.pp;
        FOR(i,N){
            if(~m>>i&1) continue;
            int m2=0;
            FOR(j,N){
                if(i!=j&&(m>>j&1)) m2|=adj[j];
            }
            if(f[m2]==-1){
                f[m2]=m;
                g[m2]=i;
                q.push(m2);
            }
        }
    }
    if(f[0]==-1){
        cout<<"NO\n";
        return 0;
    }
    cout<<"YES\n";
    vc<int> ans;
    for(int i=0;i!=(1<<N)-1;i=f[i]) ans.pb(g[i]);
    reverse(all(ans));
    cout<<sz(ans)<<"\n";
    FORR(x,ans)cout<<x+1<<" ";
    return 6/22;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 316 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 0 ms 324 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 452 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 1 ms 576 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 1 ms 596 KB Output is correct
38 Correct 1 ms 468 KB Output is correct
39 Correct 1 ms 724 KB Output is correct
40 Correct 1 ms 724 KB Output is correct
41 Correct 1 ms 724 KB Output is correct
42 Correct 1 ms 724 KB Output is correct
43 Correct 1 ms 1364 KB Output is correct
44 Correct 1 ms 1236 KB Output is correct
45 Correct 1 ms 1236 KB Output is correct
46 Correct 1 ms 1248 KB Output is correct
47 Correct 1 ms 2260 KB Output is correct
48 Correct 2 ms 2388 KB Output is correct
49 Correct 2 ms 2260 KB Output is correct
50 Correct 1 ms 2260 KB Output is correct
51 Correct 2 ms 4436 KB Output is correct
52 Correct 2 ms 4436 KB Output is correct
53 Correct 2 ms 4436 KB Output is correct
54 Correct 2 ms 4436 KB Output is correct
55 Correct 3 ms 8532 KB Output is correct
56 Correct 3 ms 8532 KB Output is correct
57 Correct 3 ms 8512 KB Output is correct
58 Correct 3 ms 8532 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 0 ms 212 KB Output is correct
61 Correct 0 ms 316 KB Output is correct
62 Correct 0 ms 212 KB Output is correct
63 Correct 0 ms 212 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Runtime error 2 ms 1492 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 316 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 0 ms 324 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 452 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 1 ms 576 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 1 ms 596 KB Output is correct
38 Correct 1 ms 468 KB Output is correct
39 Correct 1 ms 724 KB Output is correct
40 Correct 1 ms 724 KB Output is correct
41 Correct 1 ms 724 KB Output is correct
42 Correct 1 ms 724 KB Output is correct
43 Correct 1 ms 1364 KB Output is correct
44 Correct 1 ms 1236 KB Output is correct
45 Correct 1 ms 1236 KB Output is correct
46 Correct 1 ms 1248 KB Output is correct
47 Correct 1 ms 2260 KB Output is correct
48 Correct 2 ms 2388 KB Output is correct
49 Correct 2 ms 2260 KB Output is correct
50 Correct 1 ms 2260 KB Output is correct
51 Correct 2 ms 4436 KB Output is correct
52 Correct 2 ms 4436 KB Output is correct
53 Correct 2 ms 4436 KB Output is correct
54 Correct 2 ms 4436 KB Output is correct
55 Correct 3 ms 8532 KB Output is correct
56 Correct 3 ms 8532 KB Output is correct
57 Correct 3 ms 8512 KB Output is correct
58 Correct 3 ms 8532 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 0 ms 212 KB Output is correct
61 Correct 0 ms 316 KB Output is correct
62 Correct 0 ms 212 KB Output is correct
63 Correct 0 ms 212 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 1 ms 212 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 0 ms 212 KB Output is correct
68 Correct 1 ms 320 KB Output is correct
69 Correct 1 ms 212 KB Output is correct
70 Correct 0 ms 212 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 0 ms 212 KB Output is correct
73 Correct 1 ms 212 KB Output is correct
74 Correct 1 ms 212 KB Output is correct
75 Correct 1 ms 212 KB Output is correct
76 Correct 0 ms 212 KB Output is correct
77 Correct 0 ms 212 KB Output is correct
78 Correct 1 ms 212 KB Output is correct
79 Runtime error 163 ms 524288 KB Execution killed with signal 9
80 Halted 0 ms 0 KB -