답안 #1003138

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003138 2024-06-20T06:39:22 Z vjudge1 Subtree (INOI20_subtree) C++17
8 / 100
2000 ms 2904 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define inf 0x3F3F3F3F3F3F3F3F
 
const int MXN = 1e5 + 5;
const int LOG = 20;
const int mod = 1e9 + 7;

vector<int> adj[MXN];
int msk, cyc, c;
int col[MXN], par[MXN];

void dfs(int a)
{
	c++;
	col[a] = 1;
	for (int v : adj[a])
	{
		if (!(msk >> v & 1)) continue;
		if (v == par[a]) continue;
		if (col[v] == 1) cyc = 1;
		if (!col[v]) 
		{
			par[v] = a;
			dfs(v);
		}
	}
	col[a] = 2;
}

signed main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++)
  {
    int u, v;
    cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
  }
	int res = 0;
	for (msk = 1; msk < (1LL << n); msk++)
	{
		c = 0, cyc = 0;
		for (int i = 0; i < n; i++)
		{
			if (msk >> i & 1)
			{
				dfs(i);
				break;
			}
		}
		for (int i = 0; i < n; i++) par[i] = 0, col[i] = 0;
		if (c == __builtin_popcount(msk) && !cyc) res++;
	}
	cout << res << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2808 KB Output is correct
2 Correct 2 ms 2752 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 2 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 34 ms 2652 KB Output is correct
9 Correct 32 ms 2648 KB Output is correct
10 Correct 29 ms 2652 KB Output is correct
11 Correct 28 ms 2652 KB Output is correct
12 Correct 13 ms 2648 KB Output is correct
13 Correct 42 ms 2652 KB Output is correct
14 Correct 29 ms 2652 KB Output is correct
15 Correct 14 ms 2816 KB Output is correct
16 Correct 30 ms 2652 KB Output is correct
17 Correct 29 ms 2648 KB Output is correct
18 Correct 16 ms 2652 KB Output is correct
19 Correct 16 ms 2816 KB Output is correct
20 Correct 34 ms 2652 KB Output is correct
21 Correct 34 ms 2652 KB Output is correct
22 Correct 17 ms 2648 KB Output is correct
23 Correct 63 ms 2792 KB Output is correct
24 Correct 26 ms 2648 KB Output is correct
25 Correct 1 ms 2648 KB Output is correct
26 Correct 1 ms 2904 KB Output is correct
27 Correct 1 ms 2652 KB Output is correct
28 Correct 2 ms 2804 KB Output is correct
29 Correct 15 ms 2652 KB Output is correct
30 Correct 30 ms 2652 KB Output is correct
31 Correct 17 ms 2652 KB Output is correct
32 Correct 14 ms 2824 KB Output is correct
33 Correct 18 ms 2652 KB Output is correct
34 Correct 29 ms 2816 KB Output is correct
35 Correct 28 ms 2652 KB Output is correct
36 Correct 40 ms 2792 KB Output is correct
37 Correct 44 ms 2652 KB Output is correct
38 Correct 29 ms 2652 KB Output is correct
39 Correct 24 ms 2652 KB Output is correct
40 Correct 25 ms 2648 KB Output is correct
41 Correct 28 ms 2652 KB Output is correct
42 Correct 27 ms 2652 KB Output is correct
43 Correct 12 ms 2652 KB Output is correct
44 Correct 27 ms 2652 KB Output is correct
45 Correct 32 ms 2648 KB Output is correct
46 Correct 29 ms 2652 KB Output is correct
47 Correct 31 ms 2812 KB Output is correct
48 Correct 31 ms 2796 KB Output is correct
49 Correct 27 ms 2648 KB Output is correct
50 Correct 26 ms 2652 KB Output is correct
51 Correct 27 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2037 ms 2648 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2808 KB Output is correct
2 Correct 2 ms 2752 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 2 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 34 ms 2652 KB Output is correct
9 Correct 32 ms 2648 KB Output is correct
10 Correct 29 ms 2652 KB Output is correct
11 Correct 28 ms 2652 KB Output is correct
12 Correct 13 ms 2648 KB Output is correct
13 Correct 42 ms 2652 KB Output is correct
14 Correct 29 ms 2652 KB Output is correct
15 Correct 14 ms 2816 KB Output is correct
16 Correct 30 ms 2652 KB Output is correct
17 Correct 29 ms 2648 KB Output is correct
18 Correct 16 ms 2652 KB Output is correct
19 Correct 16 ms 2816 KB Output is correct
20 Correct 34 ms 2652 KB Output is correct
21 Correct 34 ms 2652 KB Output is correct
22 Correct 17 ms 2648 KB Output is correct
23 Correct 63 ms 2792 KB Output is correct
24 Correct 26 ms 2648 KB Output is correct
25 Correct 1 ms 2648 KB Output is correct
26 Correct 1 ms 2904 KB Output is correct
27 Correct 1 ms 2652 KB Output is correct
28 Correct 2 ms 2804 KB Output is correct
29 Correct 15 ms 2652 KB Output is correct
30 Correct 30 ms 2652 KB Output is correct
31 Correct 17 ms 2652 KB Output is correct
32 Correct 14 ms 2824 KB Output is correct
33 Correct 18 ms 2652 KB Output is correct
34 Correct 29 ms 2816 KB Output is correct
35 Correct 28 ms 2652 KB Output is correct
36 Correct 40 ms 2792 KB Output is correct
37 Correct 44 ms 2652 KB Output is correct
38 Correct 29 ms 2652 KB Output is correct
39 Correct 24 ms 2652 KB Output is correct
40 Correct 25 ms 2648 KB Output is correct
41 Correct 28 ms 2652 KB Output is correct
42 Correct 27 ms 2652 KB Output is correct
43 Correct 12 ms 2652 KB Output is correct
44 Correct 27 ms 2652 KB Output is correct
45 Correct 32 ms 2648 KB Output is correct
46 Correct 29 ms 2652 KB Output is correct
47 Correct 31 ms 2812 KB Output is correct
48 Correct 31 ms 2796 KB Output is correct
49 Correct 27 ms 2648 KB Output is correct
50 Correct 26 ms 2652 KB Output is correct
51 Correct 27 ms 2652 KB Output is correct
52 Incorrect 2 ms 2904 KB Output isn't correct
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2808 KB Output is correct
2 Correct 2 ms 2752 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 2 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 34 ms 2652 KB Output is correct
9 Correct 32 ms 2648 KB Output is correct
10 Correct 29 ms 2652 KB Output is correct
11 Correct 28 ms 2652 KB Output is correct
12 Correct 13 ms 2648 KB Output is correct
13 Correct 42 ms 2652 KB Output is correct
14 Correct 29 ms 2652 KB Output is correct
15 Correct 14 ms 2816 KB Output is correct
16 Correct 30 ms 2652 KB Output is correct
17 Correct 29 ms 2648 KB Output is correct
18 Correct 16 ms 2652 KB Output is correct
19 Correct 16 ms 2816 KB Output is correct
20 Correct 34 ms 2652 KB Output is correct
21 Correct 34 ms 2652 KB Output is correct
22 Correct 17 ms 2648 KB Output is correct
23 Correct 63 ms 2792 KB Output is correct
24 Correct 26 ms 2648 KB Output is correct
25 Correct 1 ms 2648 KB Output is correct
26 Correct 1 ms 2904 KB Output is correct
27 Correct 1 ms 2652 KB Output is correct
28 Correct 2 ms 2804 KB Output is correct
29 Correct 15 ms 2652 KB Output is correct
30 Correct 30 ms 2652 KB Output is correct
31 Correct 17 ms 2652 KB Output is correct
32 Correct 14 ms 2824 KB Output is correct
33 Correct 18 ms 2652 KB Output is correct
34 Correct 29 ms 2816 KB Output is correct
35 Correct 28 ms 2652 KB Output is correct
36 Correct 40 ms 2792 KB Output is correct
37 Correct 44 ms 2652 KB Output is correct
38 Correct 29 ms 2652 KB Output is correct
39 Correct 24 ms 2652 KB Output is correct
40 Correct 25 ms 2648 KB Output is correct
41 Correct 28 ms 2652 KB Output is correct
42 Correct 27 ms 2652 KB Output is correct
43 Correct 12 ms 2652 KB Output is correct
44 Correct 27 ms 2652 KB Output is correct
45 Correct 32 ms 2648 KB Output is correct
46 Correct 29 ms 2652 KB Output is correct
47 Correct 31 ms 2812 KB Output is correct
48 Correct 31 ms 2796 KB Output is correct
49 Correct 27 ms 2648 KB Output is correct
50 Correct 26 ms 2652 KB Output is correct
51 Correct 27 ms 2652 KB Output is correct
52 Execution timed out 2037 ms 2648 KB Time limit exceeded
53 Halted 0 ms 0 KB -