# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
532578 | 2022-03-03T08:47:01 Z | qwerasdfzxcl | Newspapers (CEOI21_newspapers) | C++14 | 21 ms | 16364 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; constexpr int INF = 1e9; vector<int> adj[1010]; int dist[2002000], n; pair<int, int> par[2002000]; int _relax(int msk){ int ret = 0; for (int i=1;i<=n;i++) if (msk&(1<<(i-1))){ for (auto &v:adj[i]) ret |= (1<<(v-1)); } return ret; } int dep[1010]; void dfs(int s, int pa = -1){ for (auto &v:adj[s]) if (v!=pa){ dep[v] = dep[s] + 1; dfs(v, s); } } int main(){ int m; scanf("%d %d", &n, &m); if (m>n-1) {printf("NO\n"); return 0;} for (int i=0;i<m;i++){ int x, y; scanf("%d %d", &x, &y); adj[x].push_back(y); adj[y].push_back(x); } for (int i=1;i<=n;i++){ dep[i] = 0; dfs(i); int cnt = 0; for (int j=1;j<=n;j++) if (dep[j]==3) cnt++; //if (cnt>=3) {printf("NO\n"); return 0;} } //printf("YES\n1\n1\n"); //return 0; int mx = (1<<n) - 1; fill(dist, dist+mx+1, INF); dist[mx] = 0; queue<int> q; q.push(mx); while(!q.empty()){ int s = q.front(); q.pop(); for (int i=0;i<n;i++){ int v = s & (mx ^ (1<<i)); v = _relax(v); if (dist[v]!=INF) continue; dist[v] = dist[s] + 1; par[v] = {s, i+1}; q.push(v); } } if (dist[0]==INF) printf("NO\n"); else{ printf("YES\n"); vector<int> ans; for (int cur = 0;cur!=mx;cur=par[cur].first) ans.push_back(par[cur].second); reverse(ans.begin(), ans.end()); printf("%d\n", (int)ans.size()); for (auto &x: ans) printf("%d ", x); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 0 ms | 332 KB | Output is correct |
19 | Correct | 0 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 0 ms | 332 KB | Output is correct |
22 | Correct | 0 ms | 324 KB | Output is correct |
23 | Correct | 1 ms | 332 KB | Output is correct |
24 | Correct | 1 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 1 ms | 332 KB | Output is correct |
27 | Correct | 1 ms | 332 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 1 ms | 320 KB | Output is correct |
30 | Correct | 1 ms | 332 KB | Output is correct |
31 | Correct | 1 ms | 460 KB | Output is correct |
32 | Correct | 1 ms | 460 KB | Output is correct |
33 | Correct | 1 ms | 460 KB | Output is correct |
34 | Correct | 1 ms | 332 KB | Output is correct |
35 | Correct | 1 ms | 588 KB | Output is correct |
36 | Correct | 1 ms | 588 KB | Output is correct |
37 | Correct | 1 ms | 588 KB | Output is correct |
38 | Correct | 1 ms | 588 KB | Output is correct |
39 | Correct | 1 ms | 844 KB | Output is correct |
40 | Correct | 1 ms | 972 KB | Output is correct |
41 | Correct | 1 ms | 716 KB | Output is correct |
42 | Correct | 1 ms | 844 KB | Output is correct |
43 | Correct | 1 ms | 1100 KB | Output is correct |
44 | Correct | 1 ms | 972 KB | Output is correct |
45 | Correct | 1 ms | 972 KB | Output is correct |
46 | Correct | 1 ms | 972 KB | Output is correct |
47 | Correct | 1 ms | 1612 KB | Output is correct |
48 | Correct | 1 ms | 1868 KB | Output is correct |
49 | Correct | 1 ms | 1472 KB | Output is correct |
50 | Correct | 1 ms | 1484 KB | Output is correct |
51 | Correct | 2 ms | 2884 KB | Output is correct |
52 | Correct | 2 ms | 2504 KB | Output is correct |
53 | Correct | 2 ms | 2508 KB | Output is correct |
54 | Correct | 2 ms | 2636 KB | Output is correct |
55 | Correct | 2 ms | 4684 KB | Output is correct |
56 | Correct | 3 ms | 4556 KB | Output is correct |
57 | Correct | 3 ms | 5068 KB | Output is correct |
58 | Correct | 3 ms | 4684 KB | Output is correct |
59 | Correct | 1 ms | 332 KB | Output is correct |
60 | Correct | 1 ms | 332 KB | Output is correct |
61 | Correct | 1 ms | 332 KB | Output is correct |
62 | Correct | 1 ms | 332 KB | Output is correct |
63 | Correct | 1 ms | 332 KB | Output is correct |
64 | Correct | 1 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Runtime error | 13 ms | 1156 KB | Execution killed with signal 11 |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 0 ms | 332 KB | Output is correct |
19 | Correct | 0 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 0 ms | 332 KB | Output is correct |
22 | Correct | 0 ms | 324 KB | Output is correct |
23 | Correct | 1 ms | 332 KB | Output is correct |
24 | Correct | 1 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 1 ms | 332 KB | Output is correct |
27 | Correct | 1 ms | 332 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 1 ms | 320 KB | Output is correct |
30 | Correct | 1 ms | 332 KB | Output is correct |
31 | Correct | 1 ms | 460 KB | Output is correct |
32 | Correct | 1 ms | 460 KB | Output is correct |
33 | Correct | 1 ms | 460 KB | Output is correct |
34 | Correct | 1 ms | 332 KB | Output is correct |
35 | Correct | 1 ms | 588 KB | Output is correct |
36 | Correct | 1 ms | 588 KB | Output is correct |
37 | Correct | 1 ms | 588 KB | Output is correct |
38 | Correct | 1 ms | 588 KB | Output is correct |
39 | Correct | 1 ms | 844 KB | Output is correct |
40 | Correct | 1 ms | 972 KB | Output is correct |
41 | Correct | 1 ms | 716 KB | Output is correct |
42 | Correct | 1 ms | 844 KB | Output is correct |
43 | Correct | 1 ms | 1100 KB | Output is correct |
44 | Correct | 1 ms | 972 KB | Output is correct |
45 | Correct | 1 ms | 972 KB | Output is correct |
46 | Correct | 1 ms | 972 KB | Output is correct |
47 | Correct | 1 ms | 1612 KB | Output is correct |
48 | Correct | 1 ms | 1868 KB | Output is correct |
49 | Correct | 1 ms | 1472 KB | Output is correct |
50 | Correct | 1 ms | 1484 KB | Output is correct |
51 | Correct | 2 ms | 2884 KB | Output is correct |
52 | Correct | 2 ms | 2504 KB | Output is correct |
53 | Correct | 2 ms | 2508 KB | Output is correct |
54 | Correct | 2 ms | 2636 KB | Output is correct |
55 | Correct | 2 ms | 4684 KB | Output is correct |
56 | Correct | 3 ms | 4556 KB | Output is correct |
57 | Correct | 3 ms | 5068 KB | Output is correct |
58 | Correct | 3 ms | 4684 KB | Output is correct |
59 | Correct | 1 ms | 332 KB | Output is correct |
60 | Correct | 1 ms | 332 KB | Output is correct |
61 | Correct | 1 ms | 332 KB | Output is correct |
62 | Correct | 1 ms | 332 KB | Output is correct |
63 | Correct | 1 ms | 332 KB | Output is correct |
64 | Correct | 1 ms | 332 KB | Output is correct |
65 | Correct | 1 ms | 332 KB | Output is correct |
66 | Correct | 0 ms | 332 KB | Output is correct |
67 | Correct | 0 ms | 332 KB | Output is correct |
68 | Correct | 0 ms | 332 KB | Output is correct |
69 | Correct | 0 ms | 332 KB | Output is correct |
70 | Correct | 0 ms | 332 KB | Output is correct |
71 | Correct | 1 ms | 204 KB | Output is correct |
72 | Correct | 0 ms | 332 KB | Output is correct |
73 | Correct | 0 ms | 332 KB | Output is correct |
74 | Correct | 1 ms | 332 KB | Output is correct |
75 | Correct | 0 ms | 332 KB | Output is correct |
76 | Correct | 0 ms | 332 KB | Output is correct |
77 | Correct | 1 ms | 332 KB | Output is correct |
78 | Correct | 0 ms | 332 KB | Output is correct |
79 | Runtime error | 21 ms | 16364 KB | Execution killed with signal 11 |
80 | Halted | 0 ms | 0 KB | - |