답안 #1070071

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1070071 2024-08-22T11:28:24 Z bleahbleah 참나무 (IOI23_beechtree) C++17
58 / 100
2000 ms 120312 KB
#include "beechtree.h"
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;

using ll = long long;
using ld = long double;

//#define int ll
#define sz(x) ((int)(x).size())

using pii = pair<int,int>;
using tii = tuple<int,int,int>;

const int nmax = 3e5 + 5;

vector<pii> g[nmax];
vector<int> P, C;

unordered_set<int> colors[nmax], play[nmax];
bool isanc(unordered_set<int>& A, unordered_set<int>& B) {
   if(sz(A) < sz(B)) return 0;
   for(auto &x : B)
      if(!A.count(x)) return 0;
   return 1;
}

vector<int> sol;
int h[nmax];


bool superimposable(int x, int y) { // x peste y 
   //if(sz(g[x]) == 0 || x == y) return 1;
   //if(calc[x][y]) return SI[x][y];
   map<int, int> gy;
   for(auto [a, c] : g[y]) gy[c] = a;
   //calc[x][y] = 1;
   //SI[x][y] = 1; 
   for(auto [a, c] : g[x]) {
      if(gy.count(c) == 0) { return 0; }
      if(!superimposable(a, gy[c])) { return 0; }
   }
   return 1;
}

int area[nmax];

void insert(int& works, map<int, int>& st, int node) {
   if(!works) return;
   auto it = st.upper_bound(area[node]);
   if(it == st.end());
   else if(!superimposable(node, it -> second)) { works = 0; return; }
   if(it == st.begin()); 
   else if(!superimposable(prev(it) -> second, node)) { works = 0; return; }
   st[area[node]] = node;
   return;
}

map<int, int> dfs(int node) {
   map<int, int> here;
   sol[node] = 1;
   area[node] = 1;
   
   for(auto [x, c] : g[node]) {
      auto T = dfs(x);
      area[node] += area[x];
      sol[node] &= sol[x];
      if(sz(T) > sz(here)) swap(here, T);
      for(auto [a, x] : T) insert(sol[node], here, x);
   }
   insert(sol[node], here, node);
   if(sz(g[node]) != sz(colors[node])) sol[node] = 0;
   return here;
}

std::vector<int> beechtree(int N, int M, std::vector<int> P_, std::vector<int> C_) {
   P = P_;
   C = C_;
   for(int i = 1; i < N; i++) {
      g[P[i]].emplace_back(i, C[i]);
      colors[P[i]].emplace(C[i]);
   }
   sol.assign(N, 0);
   dfs(0);
   
   
   return sol;
}

/**
      Töte es durch genaue Untersuchung\Töte es kann es nur noch schlimmer machen\Es lässt es irgendwie atmen
--
*/ 
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 40284 KB Output is correct
2 Correct 8 ms 40284 KB Output is correct
3 Correct 8 ms 40284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 40284 KB Output is correct
2 Correct 9 ms 40284 KB Output is correct
3 Correct 8 ms 40280 KB Output is correct
4 Correct 8 ms 40284 KB Output is correct
5 Correct 8 ms 40280 KB Output is correct
6 Correct 9 ms 40536 KB Output is correct
7 Correct 8 ms 40280 KB Output is correct
8 Correct 8 ms 40432 KB Output is correct
9 Correct 7 ms 40284 KB Output is correct
10 Correct 8 ms 40284 KB Output is correct
11 Correct 9 ms 40476 KB Output is correct
12 Correct 9 ms 40284 KB Output is correct
13 Correct 8 ms 40284 KB Output is correct
14 Correct 8 ms 40284 KB Output is correct
15 Correct 8 ms 40444 KB Output is correct
16 Correct 7 ms 40448 KB Output is correct
17 Correct 8 ms 40284 KB Output is correct
18 Correct 9 ms 40280 KB Output is correct
19 Correct 8 ms 40284 KB Output is correct
20 Correct 8 ms 40428 KB Output is correct
21 Correct 8 ms 40280 KB Output is correct
22 Correct 8 ms 40376 KB Output is correct
23 Correct 12 ms 40540 KB Output is correct
24 Correct 8 ms 40284 KB Output is correct
25 Correct 8 ms 40536 KB Output is correct
26 Correct 9 ms 40284 KB Output is correct
27 Correct 8 ms 40284 KB Output is correct
28 Correct 8 ms 40284 KB Output is correct
29 Correct 9 ms 40284 KB Output is correct
30 Correct 8 ms 40280 KB Output is correct
31 Correct 8 ms 40284 KB Output is correct
32 Correct 9 ms 40284 KB Output is correct
33 Correct 8 ms 40284 KB Output is correct
34 Correct 7 ms 40284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 40284 KB Output is correct
2 Correct 9 ms 40284 KB Output is correct
3 Correct 8 ms 40280 KB Output is correct
4 Correct 8 ms 40284 KB Output is correct
5 Correct 8 ms 40280 KB Output is correct
6 Correct 9 ms 40536 KB Output is correct
7 Correct 101 ms 117836 KB Output is correct
8 Correct 110 ms 120312 KB Output is correct
9 Correct 10 ms 40536 KB Output is correct
10 Correct 8 ms 40540 KB Output is correct
11 Correct 11 ms 40540 KB Output is correct
12 Correct 8 ms 40540 KB Output is correct
13 Correct 80 ms 41236 KB Output is correct
14 Correct 57 ms 41296 KB Output is correct
15 Correct 8 ms 41052 KB Output is correct
16 Correct 8 ms 41132 KB Output is correct
17 Execution timed out 2069 ms 120092 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 40284 KB Output is correct
2 Correct 8 ms 40464 KB Output is correct
3 Correct 9 ms 40284 KB Output is correct
4 Correct 7 ms 40284 KB Output is correct
5 Correct 9 ms 40280 KB Output is correct
6 Correct 8 ms 40284 KB Output is correct
7 Correct 9 ms 40284 KB Output is correct
8 Correct 10 ms 40284 KB Output is correct
9 Correct 7 ms 40284 KB Output is correct
10 Correct 8 ms 40280 KB Output is correct
11 Correct 8 ms 40476 KB Output is correct
12 Correct 9 ms 40424 KB Output is correct
13 Correct 8 ms 40540 KB Output is correct
14 Correct 8 ms 40540 KB Output is correct
15 Correct 77 ms 51424 KB Output is correct
16 Correct 79 ms 50864 KB Output is correct
17 Correct 84 ms 51208 KB Output is correct
18 Correct 88 ms 51284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 40284 KB Output is correct
2 Correct 9 ms 40284 KB Output is correct
3 Correct 8 ms 40280 KB Output is correct
4 Correct 8 ms 40432 KB Output is correct
5 Correct 101 ms 117836 KB Output is correct
6 Correct 110 ms 120312 KB Output is correct
7 Correct 8 ms 40280 KB Output is correct
8 Correct 8 ms 40280 KB Output is correct
9 Correct 8 ms 40540 KB Output is correct
10 Correct 10 ms 40540 KB Output is correct
11 Correct 98 ms 68400 KB Output is correct
12 Execution timed out 2064 ms 57672 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 40284 KB Output is correct
2 Correct 8 ms 40284 KB Output is correct
3 Correct 8 ms 40284 KB Output is correct
4 Correct 10 ms 40284 KB Output is correct
5 Correct 9 ms 40284 KB Output is correct
6 Correct 8 ms 40280 KB Output is correct
7 Correct 8 ms 40284 KB Output is correct
8 Correct 8 ms 40280 KB Output is correct
9 Correct 9 ms 40536 KB Output is correct
10 Correct 8 ms 40280 KB Output is correct
11 Correct 8 ms 40432 KB Output is correct
12 Correct 7 ms 40284 KB Output is correct
13 Correct 8 ms 40284 KB Output is correct
14 Correct 9 ms 40476 KB Output is correct
15 Correct 9 ms 40284 KB Output is correct
16 Correct 8 ms 40284 KB Output is correct
17 Correct 8 ms 40284 KB Output is correct
18 Correct 8 ms 40444 KB Output is correct
19 Correct 7 ms 40448 KB Output is correct
20 Correct 8 ms 40284 KB Output is correct
21 Correct 9 ms 40280 KB Output is correct
22 Correct 8 ms 40284 KB Output is correct
23 Correct 8 ms 40428 KB Output is correct
24 Correct 8 ms 40280 KB Output is correct
25 Correct 8 ms 40376 KB Output is correct
26 Correct 12 ms 40540 KB Output is correct
27 Correct 8 ms 40284 KB Output is correct
28 Correct 8 ms 40536 KB Output is correct
29 Correct 9 ms 40284 KB Output is correct
30 Correct 8 ms 40284 KB Output is correct
31 Correct 8 ms 40284 KB Output is correct
32 Correct 9 ms 40284 KB Output is correct
33 Correct 8 ms 40280 KB Output is correct
34 Correct 8 ms 40284 KB Output is correct
35 Correct 9 ms 40284 KB Output is correct
36 Correct 8 ms 40284 KB Output is correct
37 Correct 7 ms 40284 KB Output is correct
38 Correct 10 ms 40536 KB Output is correct
39 Correct 8 ms 40540 KB Output is correct
40 Correct 11 ms 40540 KB Output is correct
41 Correct 8 ms 40540 KB Output is correct
42 Correct 9 ms 40284 KB Output is correct
43 Correct 8 ms 40464 KB Output is correct
44 Correct 9 ms 40284 KB Output is correct
45 Correct 7 ms 40284 KB Output is correct
46 Correct 9 ms 40280 KB Output is correct
47 Correct 8 ms 40284 KB Output is correct
48 Correct 9 ms 40284 KB Output is correct
49 Correct 10 ms 40284 KB Output is correct
50 Correct 7 ms 40284 KB Output is correct
51 Correct 8 ms 40280 KB Output is correct
52 Correct 8 ms 40280 KB Output is correct
53 Correct 8 ms 40280 KB Output is correct
54 Correct 8 ms 40284 KB Output is correct
55 Correct 8 ms 40284 KB Output is correct
56 Correct 8 ms 40284 KB Output is correct
57 Correct 9 ms 40284 KB Output is correct
58 Correct 12 ms 40284 KB Output is correct
59 Correct 11 ms 40284 KB Output is correct
60 Correct 8 ms 40284 KB Output is correct
61 Correct 9 ms 40284 KB Output is correct
62 Correct 8 ms 40284 KB Output is correct
63 Correct 8 ms 40284 KB Output is correct
64 Correct 8 ms 40284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 40284 KB Output is correct
2 Correct 9 ms 40284 KB Output is correct
3 Correct 8 ms 40280 KB Output is correct
4 Correct 8 ms 40432 KB Output is correct
5 Correct 7 ms 40284 KB Output is correct
6 Correct 8 ms 40284 KB Output is correct
7 Correct 9 ms 40476 KB Output is correct
8 Correct 9 ms 40284 KB Output is correct
9 Correct 8 ms 40284 KB Output is correct
10 Correct 8 ms 40284 KB Output is correct
11 Correct 8 ms 40444 KB Output is correct
12 Correct 7 ms 40448 KB Output is correct
13 Correct 8 ms 40284 KB Output is correct
14 Correct 9 ms 40280 KB Output is correct
15 Correct 8 ms 40284 KB Output is correct
16 Correct 8 ms 40428 KB Output is correct
17 Correct 8 ms 40280 KB Output is correct
18 Correct 8 ms 40376 KB Output is correct
19 Correct 12 ms 40540 KB Output is correct
20 Correct 8 ms 40284 KB Output is correct
21 Correct 8 ms 40536 KB Output is correct
22 Correct 9 ms 40284 KB Output is correct
23 Correct 8 ms 40284 KB Output is correct
24 Correct 8 ms 40284 KB Output is correct
25 Correct 86 ms 41308 KB Output is correct
26 Correct 48 ms 41328 KB Output is correct
27 Correct 35 ms 41308 KB Output is correct
28 Correct 9 ms 41224 KB Output is correct
29 Correct 89 ms 41344 KB Output is correct
30 Correct 15 ms 40960 KB Output is correct
31 Correct 11 ms 40712 KB Output is correct
32 Correct 10 ms 40796 KB Output is correct
33 Correct 9 ms 40792 KB Output is correct
34 Correct 10 ms 40536 KB Output is correct
35 Correct 11 ms 40536 KB Output is correct
36 Correct 9 ms 40540 KB Output is correct
37 Correct 28 ms 40904 KB Output is correct
38 Correct 17 ms 40952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 40284 KB Output is correct
2 Correct 8 ms 40284 KB Output is correct
3 Correct 8 ms 40284 KB Output is correct
4 Correct 10 ms 40284 KB Output is correct
5 Correct 9 ms 40284 KB Output is correct
6 Correct 8 ms 40280 KB Output is correct
7 Correct 8 ms 40284 KB Output is correct
8 Correct 8 ms 40280 KB Output is correct
9 Correct 9 ms 40536 KB Output is correct
10 Correct 8 ms 40280 KB Output is correct
11 Correct 8 ms 40432 KB Output is correct
12 Correct 7 ms 40284 KB Output is correct
13 Correct 8 ms 40284 KB Output is correct
14 Correct 9 ms 40476 KB Output is correct
15 Correct 9 ms 40284 KB Output is correct
16 Correct 8 ms 40284 KB Output is correct
17 Correct 8 ms 40284 KB Output is correct
18 Correct 8 ms 40444 KB Output is correct
19 Correct 7 ms 40448 KB Output is correct
20 Correct 8 ms 40284 KB Output is correct
21 Correct 9 ms 40280 KB Output is correct
22 Correct 8 ms 40284 KB Output is correct
23 Correct 8 ms 40428 KB Output is correct
24 Correct 8 ms 40280 KB Output is correct
25 Correct 8 ms 40376 KB Output is correct
26 Correct 12 ms 40540 KB Output is correct
27 Correct 8 ms 40284 KB Output is correct
28 Correct 8 ms 40536 KB Output is correct
29 Correct 9 ms 40284 KB Output is correct
30 Correct 8 ms 40284 KB Output is correct
31 Correct 8 ms 40284 KB Output is correct
32 Correct 9 ms 40284 KB Output is correct
33 Correct 8 ms 40280 KB Output is correct
34 Correct 8 ms 40284 KB Output is correct
35 Correct 9 ms 40284 KB Output is correct
36 Correct 8 ms 40284 KB Output is correct
37 Correct 7 ms 40284 KB Output is correct
38 Correct 10 ms 40536 KB Output is correct
39 Correct 8 ms 40540 KB Output is correct
40 Correct 11 ms 40540 KB Output is correct
41 Correct 8 ms 40540 KB Output is correct
42 Correct 80 ms 41236 KB Output is correct
43 Correct 57 ms 41296 KB Output is correct
44 Correct 8 ms 41052 KB Output is correct
45 Correct 8 ms 41132 KB Output is correct
46 Correct 9 ms 40284 KB Output is correct
47 Correct 8 ms 40464 KB Output is correct
48 Correct 9 ms 40284 KB Output is correct
49 Correct 7 ms 40284 KB Output is correct
50 Correct 9 ms 40280 KB Output is correct
51 Correct 8 ms 40284 KB Output is correct
52 Correct 9 ms 40284 KB Output is correct
53 Correct 10 ms 40284 KB Output is correct
54 Correct 7 ms 40284 KB Output is correct
55 Correct 8 ms 40280 KB Output is correct
56 Correct 8 ms 40476 KB Output is correct
57 Correct 9 ms 40424 KB Output is correct
58 Correct 8 ms 40540 KB Output is correct
59 Correct 8 ms 40540 KB Output is correct
60 Correct 8 ms 40280 KB Output is correct
61 Correct 8 ms 40280 KB Output is correct
62 Correct 8 ms 40540 KB Output is correct
63 Correct 10 ms 40540 KB Output is correct
64 Correct 8 ms 40284 KB Output is correct
65 Correct 8 ms 40284 KB Output is correct
66 Correct 8 ms 40284 KB Output is correct
67 Correct 9 ms 40284 KB Output is correct
68 Correct 12 ms 40284 KB Output is correct
69 Correct 11 ms 40284 KB Output is correct
70 Correct 8 ms 40284 KB Output is correct
71 Correct 9 ms 40284 KB Output is correct
72 Correct 8 ms 40284 KB Output is correct
73 Correct 8 ms 40284 KB Output is correct
74 Correct 8 ms 40284 KB Output is correct
75 Correct 86 ms 41308 KB Output is correct
76 Correct 48 ms 41328 KB Output is correct
77 Correct 35 ms 41308 KB Output is correct
78 Correct 9 ms 41224 KB Output is correct
79 Correct 89 ms 41344 KB Output is correct
80 Correct 15 ms 40960 KB Output is correct
81 Correct 11 ms 40712 KB Output is correct
82 Correct 10 ms 40796 KB Output is correct
83 Correct 9 ms 40792 KB Output is correct
84 Correct 10 ms 40536 KB Output is correct
85 Correct 11 ms 40536 KB Output is correct
86 Correct 9 ms 40540 KB Output is correct
87 Correct 28 ms 40904 KB Output is correct
88 Correct 17 ms 40952 KB Output is correct
89 Correct 49 ms 41052 KB Output is correct
90 Correct 14 ms 40796 KB Output is correct
91 Correct 10 ms 40796 KB Output is correct
92 Correct 10 ms 40796 KB Output is correct
93 Correct 11 ms 40808 KB Output is correct
94 Correct 11 ms 40692 KB Output is correct
95 Correct 11 ms 40536 KB Output is correct
96 Correct 10 ms 40540 KB Output is correct
97 Correct 28 ms 40912 KB Output is correct
98 Correct 18 ms 40932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 40284 KB Output is correct
2 Correct 9 ms 40284 KB Output is correct
3 Correct 8 ms 40280 KB Output is correct
4 Correct 8 ms 40432 KB Output is correct
5 Correct 7 ms 40284 KB Output is correct
6 Correct 8 ms 40284 KB Output is correct
7 Correct 9 ms 40476 KB Output is correct
8 Correct 9 ms 40284 KB Output is correct
9 Correct 8 ms 40284 KB Output is correct
10 Correct 8 ms 40284 KB Output is correct
11 Correct 8 ms 40444 KB Output is correct
12 Correct 7 ms 40448 KB Output is correct
13 Correct 8 ms 40284 KB Output is correct
14 Correct 9 ms 40280 KB Output is correct
15 Correct 8 ms 40284 KB Output is correct
16 Correct 8 ms 40428 KB Output is correct
17 Correct 8 ms 40280 KB Output is correct
18 Correct 8 ms 40376 KB Output is correct
19 Correct 12 ms 40540 KB Output is correct
20 Correct 8 ms 40284 KB Output is correct
21 Correct 8 ms 40536 KB Output is correct
22 Correct 9 ms 40284 KB Output is correct
23 Correct 8 ms 40284 KB Output is correct
24 Correct 8 ms 40284 KB Output is correct
25 Correct 86 ms 41308 KB Output is correct
26 Correct 48 ms 41328 KB Output is correct
27 Correct 35 ms 41308 KB Output is correct
28 Correct 9 ms 41224 KB Output is correct
29 Correct 89 ms 41344 KB Output is correct
30 Correct 15 ms 40960 KB Output is correct
31 Correct 11 ms 40712 KB Output is correct
32 Correct 10 ms 40796 KB Output is correct
33 Correct 9 ms 40792 KB Output is correct
34 Correct 10 ms 40536 KB Output is correct
35 Correct 11 ms 40536 KB Output is correct
36 Correct 9 ms 40540 KB Output is correct
37 Correct 28 ms 40904 KB Output is correct
38 Correct 17 ms 40952 KB Output is correct
39 Execution timed out 2086 ms 118004 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 40284 KB Output is correct
2 Correct 8 ms 40284 KB Output is correct
3 Correct 8 ms 40284 KB Output is correct
4 Correct 10 ms 40284 KB Output is correct
5 Correct 9 ms 40284 KB Output is correct
6 Correct 8 ms 40280 KB Output is correct
7 Correct 8 ms 40284 KB Output is correct
8 Correct 8 ms 40280 KB Output is correct
9 Correct 9 ms 40536 KB Output is correct
10 Correct 8 ms 40280 KB Output is correct
11 Correct 8 ms 40432 KB Output is correct
12 Correct 7 ms 40284 KB Output is correct
13 Correct 8 ms 40284 KB Output is correct
14 Correct 9 ms 40476 KB Output is correct
15 Correct 9 ms 40284 KB Output is correct
16 Correct 8 ms 40284 KB Output is correct
17 Correct 8 ms 40284 KB Output is correct
18 Correct 8 ms 40444 KB Output is correct
19 Correct 7 ms 40448 KB Output is correct
20 Correct 8 ms 40284 KB Output is correct
21 Correct 9 ms 40280 KB Output is correct
22 Correct 8 ms 40284 KB Output is correct
23 Correct 8 ms 40428 KB Output is correct
24 Correct 8 ms 40280 KB Output is correct
25 Correct 8 ms 40376 KB Output is correct
26 Correct 12 ms 40540 KB Output is correct
27 Correct 8 ms 40284 KB Output is correct
28 Correct 8 ms 40536 KB Output is correct
29 Correct 9 ms 40284 KB Output is correct
30 Correct 8 ms 40284 KB Output is correct
31 Correct 8 ms 40284 KB Output is correct
32 Correct 9 ms 40284 KB Output is correct
33 Correct 8 ms 40280 KB Output is correct
34 Correct 8 ms 40284 KB Output is correct
35 Correct 9 ms 40284 KB Output is correct
36 Correct 8 ms 40284 KB Output is correct
37 Correct 7 ms 40284 KB Output is correct
38 Correct 101 ms 117836 KB Output is correct
39 Correct 110 ms 120312 KB Output is correct
40 Correct 10 ms 40536 KB Output is correct
41 Correct 8 ms 40540 KB Output is correct
42 Correct 11 ms 40540 KB Output is correct
43 Correct 8 ms 40540 KB Output is correct
44 Correct 80 ms 41236 KB Output is correct
45 Correct 57 ms 41296 KB Output is correct
46 Correct 8 ms 41052 KB Output is correct
47 Correct 8 ms 41132 KB Output is correct
48 Execution timed out 2069 ms 120092 KB Time limit exceeded
49 Halted 0 ms 0 KB -