답안 #468974

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
468974 2021-08-30T10:00:51 Z sinamhdv Subtree (INOI20_subtree) C++11
8 / 100
2000 ms 460 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod = 1000 * 1000 * 1000 + 7;
const int INF = 1e9 + 100;
const ll LINF = 1e18 + 100;

#ifdef DEBUG
#define dbg(x) cout << #x << " = " << (x) << endl << flush;
#define dbgr(s, f) { cout << #s << ": "; for (auto _ = (s); _ != (f); _++) cout << *_ << ' '; cout << endl << flush; }
#else
#define dbg(x) ;
#define dbgr(s, f) ;
#endif
#define fast_io ios::sync_with_stdio(0); cin.tie(0);
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int MAXN = 22;

int n, m;
int adj[MAXN];
int ans;
int cn;

int dpar[MAXN];

inline int getroot(int x)
{
	return dpar[x] == x ? x : dpar[x] = getroot(dpar[x]);
}

inline void merge(int x, int y)
{
	x =  getroot(x);
	y = getroot(y);
	if (x == y) return;
	dpar[x] = y;
	cn--;
}

int32_t main(void)
{
	fast_io;
	cin >> n >> m;
	FOR(i, 0, m)
	{
		int x, y;
		cin >> x >> y;
		x--; y--;
		adj[x] |= (1 << y);
		adj[y] |= (1 << x);
	}

	FOR(mask, 1, 1 << n)
	{
		int e = 0;
		int sz = __builtin_popcount(mask);
		FOR(i, 0, n) if (mask >> i & 1) e += __builtin_popcount(adj[i] & mask);
		e /= 2;
		if (e != sz - 1) continue;
		iota(dpar, dpar + n + 1, 0);
		cn = sz;
		FOR(i, 0, n) if (mask >> i & 1) FOR(j, 0, n) if ((adj[i] & mask) >> j & 1) merge(i, j);
		if (cn == 1) ans++;
	}

	cout << ans << endl;


	return 0;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 116 ms 288 KB Output is correct
9 Correct 120 ms 292 KB Output is correct
10 Correct 122 ms 324 KB Output is correct
11 Correct 124 ms 292 KB Output is correct
12 Correct 53 ms 204 KB Output is correct
13 Correct 119 ms 296 KB Output is correct
14 Correct 115 ms 288 KB Output is correct
15 Correct 50 ms 292 KB Output is correct
16 Correct 140 ms 288 KB Output is correct
17 Correct 121 ms 300 KB Output is correct
18 Correct 53 ms 204 KB Output is correct
19 Correct 53 ms 204 KB Output is correct
20 Correct 115 ms 292 KB Output is correct
21 Correct 125 ms 204 KB Output is correct
22 Correct 71 ms 300 KB Output is correct
23 Correct 163 ms 288 KB Output is correct
24 Correct 117 ms 292 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 312 KB Output is correct
28 Correct 4 ms 204 KB Output is correct
29 Correct 52 ms 292 KB Output is correct
30 Correct 111 ms 204 KB Output is correct
31 Correct 59 ms 204 KB Output is correct
32 Correct 51 ms 288 KB Output is correct
33 Correct 57 ms 204 KB Output is correct
34 Correct 120 ms 292 KB Output is correct
35 Correct 122 ms 300 KB Output is correct
36 Correct 122 ms 204 KB Output is correct
37 Correct 130 ms 204 KB Output is correct
38 Correct 104 ms 288 KB Output is correct
39 Correct 106 ms 324 KB Output is correct
40 Correct 106 ms 292 KB Output is correct
41 Correct 102 ms 296 KB Output is correct
42 Correct 107 ms 292 KB Output is correct
43 Correct 51 ms 292 KB Output is correct
44 Correct 114 ms 288 KB Output is correct
45 Correct 119 ms 288 KB Output is correct
46 Correct 118 ms 300 KB Output is correct
47 Correct 137 ms 296 KB Output is correct
48 Correct 129 ms 324 KB Output is correct
49 Correct 109 ms 204 KB Output is correct
50 Correct 105 ms 288 KB Output is correct
51 Correct 104 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2054 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 116 ms 288 KB Output is correct
9 Correct 120 ms 292 KB Output is correct
10 Correct 122 ms 324 KB Output is correct
11 Correct 124 ms 292 KB Output is correct
12 Correct 53 ms 204 KB Output is correct
13 Correct 119 ms 296 KB Output is correct
14 Correct 115 ms 288 KB Output is correct
15 Correct 50 ms 292 KB Output is correct
16 Correct 140 ms 288 KB Output is correct
17 Correct 121 ms 300 KB Output is correct
18 Correct 53 ms 204 KB Output is correct
19 Correct 53 ms 204 KB Output is correct
20 Correct 115 ms 292 KB Output is correct
21 Correct 125 ms 204 KB Output is correct
22 Correct 71 ms 300 KB Output is correct
23 Correct 163 ms 288 KB Output is correct
24 Correct 117 ms 292 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 312 KB Output is correct
28 Correct 4 ms 204 KB Output is correct
29 Correct 52 ms 292 KB Output is correct
30 Correct 111 ms 204 KB Output is correct
31 Correct 59 ms 204 KB Output is correct
32 Correct 51 ms 288 KB Output is correct
33 Correct 57 ms 204 KB Output is correct
34 Correct 120 ms 292 KB Output is correct
35 Correct 122 ms 300 KB Output is correct
36 Correct 122 ms 204 KB Output is correct
37 Correct 130 ms 204 KB Output is correct
38 Correct 104 ms 288 KB Output is correct
39 Correct 106 ms 324 KB Output is correct
40 Correct 106 ms 292 KB Output is correct
41 Correct 102 ms 296 KB Output is correct
42 Correct 107 ms 292 KB Output is correct
43 Correct 51 ms 292 KB Output is correct
44 Correct 114 ms 288 KB Output is correct
45 Correct 119 ms 288 KB Output is correct
46 Correct 118 ms 300 KB Output is correct
47 Correct 137 ms 296 KB Output is correct
48 Correct 129 ms 324 KB Output is correct
49 Correct 109 ms 204 KB Output is correct
50 Correct 105 ms 288 KB Output is correct
51 Correct 104 ms 204 KB Output is correct
52 Runtime error 1 ms 460 KB Execution killed with signal 11
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 116 ms 288 KB Output is correct
9 Correct 120 ms 292 KB Output is correct
10 Correct 122 ms 324 KB Output is correct
11 Correct 124 ms 292 KB Output is correct
12 Correct 53 ms 204 KB Output is correct
13 Correct 119 ms 296 KB Output is correct
14 Correct 115 ms 288 KB Output is correct
15 Correct 50 ms 292 KB Output is correct
16 Correct 140 ms 288 KB Output is correct
17 Correct 121 ms 300 KB Output is correct
18 Correct 53 ms 204 KB Output is correct
19 Correct 53 ms 204 KB Output is correct
20 Correct 115 ms 292 KB Output is correct
21 Correct 125 ms 204 KB Output is correct
22 Correct 71 ms 300 KB Output is correct
23 Correct 163 ms 288 KB Output is correct
24 Correct 117 ms 292 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 312 KB Output is correct
28 Correct 4 ms 204 KB Output is correct
29 Correct 52 ms 292 KB Output is correct
30 Correct 111 ms 204 KB Output is correct
31 Correct 59 ms 204 KB Output is correct
32 Correct 51 ms 288 KB Output is correct
33 Correct 57 ms 204 KB Output is correct
34 Correct 120 ms 292 KB Output is correct
35 Correct 122 ms 300 KB Output is correct
36 Correct 122 ms 204 KB Output is correct
37 Correct 130 ms 204 KB Output is correct
38 Correct 104 ms 288 KB Output is correct
39 Correct 106 ms 324 KB Output is correct
40 Correct 106 ms 292 KB Output is correct
41 Correct 102 ms 296 KB Output is correct
42 Correct 107 ms 292 KB Output is correct
43 Correct 51 ms 292 KB Output is correct
44 Correct 114 ms 288 KB Output is correct
45 Correct 119 ms 288 KB Output is correct
46 Correct 118 ms 300 KB Output is correct
47 Correct 137 ms 296 KB Output is correct
48 Correct 129 ms 324 KB Output is correct
49 Correct 109 ms 204 KB Output is correct
50 Correct 105 ms 288 KB Output is correct
51 Correct 104 ms 204 KB Output is correct
52 Execution timed out 2054 ms 204 KB Time limit exceeded
53 Halted 0 ms 0 KB -