# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
532580 | 2022-03-03T08:50:47 Z | qwerasdfzxcl | Newspapers (CEOI21_newspapers) | C++14 | 27 ms | 16480 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], pos[1010]; void dfs(int s, int pa = -1){ for (auto &v:adj[s]) if (v!=pa){ dep[v] = dep[s] + 1; if (pa==-1) pos[v] = v; else pos[v] = pos[s]; 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); set<int> S; for (int j=1;j<=n;j++) if (dep[j]==3) S.insert(pos[j]); if (S.size()>=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 | 1 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 | 1 ms | 332 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 | 0 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 0 ms | 332 KB | Output is correct |
12 | Correct | 0 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 | 1 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 0 ms | 332 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 0 ms | 332 KB | Output is correct |
21 | Correct | 0 ms | 332 KB | Output is correct |
22 | Correct | 0 ms | 332 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 | 0 ms | 332 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 | 844 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 | 0 ms | 332 KB | Output is correct |
46 | Correct | 1 ms | 332 KB | Output is correct |
47 | Correct | 0 ms | 332 KB | Output is correct |
48 | Correct | 1 ms | 1868 KB | Output is correct |
49 | Correct | 0 ms | 332 KB | Output is correct |
50 | Correct | 0 ms | 332 KB | Output is correct |
51 | Correct | 2 ms | 2892 KB | Output is correct |
52 | Correct | 0 ms | 332 KB | Output is correct |
53 | Correct | 0 ms | 328 KB | Output is correct |
54 | Correct | 2 ms | 2636 KB | Output is correct |
55 | Correct | 0 ms | 332 KB | Output is correct |
56 | Correct | 0 ms | 332 KB | Output is correct |
57 | Correct | 0 ms | 332 KB | Output is correct |
58 | Correct | 1 ms | 332 KB | Output is correct |
59 | Correct | 0 ms | 204 KB | Output is correct |
60 | Correct | 0 ms | 204 KB | Output is correct |
61 | Correct | 0 ms | 204 KB | Output is correct |
62 | Correct | 0 ms | 204 KB | Output is correct |
63 | Correct | 0 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 | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 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 | 14 ms | 1228 KB | Execution killed with signal 11 |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 332 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 | 0 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 0 ms | 332 KB | Output is correct |
12 | Correct | 0 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 | 1 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 0 ms | 332 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 0 ms | 332 KB | Output is correct |
21 | Correct | 0 ms | 332 KB | Output is correct |
22 | Correct | 0 ms | 332 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 | 0 ms | 332 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 | 844 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 | 0 ms | 332 KB | Output is correct |
46 | Correct | 1 ms | 332 KB | Output is correct |
47 | Correct | 0 ms | 332 KB | Output is correct |
48 | Correct | 1 ms | 1868 KB | Output is correct |
49 | Correct | 0 ms | 332 KB | Output is correct |
50 | Correct | 0 ms | 332 KB | Output is correct |
51 | Correct | 2 ms | 2892 KB | Output is correct |
52 | Correct | 0 ms | 332 KB | Output is correct |
53 | Correct | 0 ms | 328 KB | Output is correct |
54 | Correct | 2 ms | 2636 KB | Output is correct |
55 | Correct | 0 ms | 332 KB | Output is correct |
56 | Correct | 0 ms | 332 KB | Output is correct |
57 | Correct | 0 ms | 332 KB | Output is correct |
58 | Correct | 1 ms | 332 KB | Output is correct |
59 | Correct | 0 ms | 204 KB | Output is correct |
60 | Correct | 0 ms | 204 KB | Output is correct |
61 | Correct | 0 ms | 204 KB | Output is correct |
62 | Correct | 0 ms | 204 KB | Output is correct |
63 | Correct | 0 ms | 332 KB | Output is correct |
64 | Correct | 1 ms | 332 KB | Output is correct |
65 | Correct | 0 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 | 1 ms | 332 KB | Output is correct |
70 | Correct | 0 ms | 332 KB | Output is correct |
71 | Correct | 0 ms | 332 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 | 0 ms | 332 KB | Output is correct |
78 | Correct | 0 ms | 332 KB | Output is correct |
79 | Correct | 1 ms | 332 KB | Output is correct |
80 | Correct | 1 ms | 328 KB | Output is correct |
81 | Correct | 1 ms | 332 KB | Output is correct |
82 | Correct | 1 ms | 332 KB | Output is correct |
83 | Correct | 1 ms | 332 KB | Output is correct |
84 | Correct | 1 ms | 332 KB | Output is correct |
85 | Correct | 1 ms | 332 KB | Output is correct |
86 | Correct | 1 ms | 332 KB | Output is correct |
87 | Correct | 1 ms | 332 KB | Output is correct |
88 | Correct | 1 ms | 332 KB | Output is correct |
89 | Runtime error | 27 ms | 16480 KB | Execution killed with signal 11 |
90 | Halted | 0 ms | 0 KB | - |