답안 #519309

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
519309 2022-01-26T07:44:18 Z Keshi Newspapers (CEOI21_newspapers) C++17
12 / 100
1 ms 2124 KB
//In the name of God
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll maxn = 2e6 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()

ll pw(ll a, ll b){
	ll c = 1;
	while(b){
		if(b & 1) c = c * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return c;
}

int n, m, g[maxn], d[maxn], p[maxn], pp[maxn];
bool vis[maxn];
queue<int> q;

int get(int x){
	int y = 0;
	for(int i = 0; i < n; i++){
		if((x >> i) & 1) y |= g[i];
	}
	return y;
}

int main(){
	fast_io;

	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int v, u;
		cin >> v >> u;
		v--;
		u--;
		g[v] |= (1 << u);
		g[u] |= (1 << v);
	}
	p[(1 << n) - 1] = -1;
	vis[(1 << n) - 1] = 1;
	q.push((1 << n) - 1);
	while(!q.empty()){
		int v = q.front();
		q.pop();
		for(int i = 0; i < n; i++){
			int u = get(v & (~(1 << i)));
			if(!vis[u]){
				vis[u] = 1;
				d[u] = d[v] + 1;
				p[u] = v;
				pp[u] = i;
				q.push(u);
			}
		}
	}
	if(!vis[0]){
		cout << "NO\n";
		return 0;
	}
	cout << "YES\n";
	cout << d[0] << "\n";
	int v = 0;
	vector<int> vec;
	while(p[v] != -1){
		vec.pb(pp[v]);
		v = p[v];
	}
	reverse(all(vec));
	for(int i : vec){
		cout << i + 1 << " ";
	}

	
	return 0;
}
# 결과 실행 시간 메모리 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 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 324 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 0 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 0 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 320 KB Output is correct
28 Correct 1 ms 456 KB Output is correct
29 Correct 1 ms 324 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 444 KB Output is correct
35 Correct 1 ms 716 KB Output is correct
36 Correct 1 ms 716 KB Output is correct
37 Correct 1 ms 708 KB Output is correct
38 Correct 1 ms 700 KB Output is correct
39 Correct 1 ms 956 KB Output is correct
40 Correct 1 ms 1088 KB Output is correct
41 Correct 1 ms 588 KB Output is correct
42 Correct 1 ms 972 KB Output is correct
43 Correct 1 ms 1100 KB Output is correct
44 Correct 1 ms 844 KB Output is correct
45 Correct 1 ms 844 KB Output is correct
46 Correct 1 ms 716 KB Output is correct
47 Correct 1 ms 1216 KB Output is correct
48 Correct 1 ms 1740 KB Output is correct
49 Correct 1 ms 716 KB Output is correct
50 Correct 1 ms 844 KB Output is correct
51 Correct 1 ms 1612 KB Output is correct
52 Correct 1 ms 716 KB Output is correct
53 Correct 1 ms 972 KB Output is correct
54 Correct 1 ms 1216 KB Output is correct
55 Correct 1 ms 1100 KB Output is correct
56 Correct 1 ms 588 KB Output is correct
57 Correct 1 ms 2124 KB Output is correct
58 Correct 1 ms 972 KB Output is correct
59 Correct 0 ms 324 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 0 ms 336 KB Output is correct
62 Correct 0 ms 332 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 0 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 0 ms 340 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 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Runtime error 1 ms 468 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 0 ms 332 KB Output is correct
3 Correct 0 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 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 0 ms 324 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 324 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 0 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 0 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 320 KB Output is correct
28 Correct 1 ms 456 KB Output is correct
29 Correct 1 ms 324 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 444 KB Output is correct
35 Correct 1 ms 716 KB Output is correct
36 Correct 1 ms 716 KB Output is correct
37 Correct 1 ms 708 KB Output is correct
38 Correct 1 ms 700 KB Output is correct
39 Correct 1 ms 956 KB Output is correct
40 Correct 1 ms 1088 KB Output is correct
41 Correct 1 ms 588 KB Output is correct
42 Correct 1 ms 972 KB Output is correct
43 Correct 1 ms 1100 KB Output is correct
44 Correct 1 ms 844 KB Output is correct
45 Correct 1 ms 844 KB Output is correct
46 Correct 1 ms 716 KB Output is correct
47 Correct 1 ms 1216 KB Output is correct
48 Correct 1 ms 1740 KB Output is correct
49 Correct 1 ms 716 KB Output is correct
50 Correct 1 ms 844 KB Output is correct
51 Correct 1 ms 1612 KB Output is correct
52 Correct 1 ms 716 KB Output is correct
53 Correct 1 ms 972 KB Output is correct
54 Correct 1 ms 1216 KB Output is correct
55 Correct 1 ms 1100 KB Output is correct
56 Correct 1 ms 588 KB Output is correct
57 Correct 1 ms 2124 KB Output is correct
58 Correct 1 ms 972 KB Output is correct
59 Correct 0 ms 324 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 0 ms 336 KB Output is correct
62 Correct 0 ms 332 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 0 ms 336 KB Output is correct
65 Correct 1 ms 332 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 0 ms 320 KB Output is correct
68 Correct 0 ms 340 KB Output is correct
69 Correct 0 ms 340 KB Output is correct
70 Correct 0 ms 332 KB Output is correct
71 Correct 0 ms 336 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 0 ms 324 KB Output is correct
74 Correct 0 ms 324 KB Output is correct
75 Correct 0 ms 340 KB Output is correct
76 Correct 0 ms 340 KB Output is correct
77 Correct 1 ms 340 KB Output is correct
78 Correct 0 ms 328 KB Output is correct
79 Runtime error 1 ms 468 KB Execution killed with signal 11
80 Halted 0 ms 0 KB -