# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1031551 | 2024-07-23T00:42:30 Z | aaaaaarroz | Beech Tree (IOI23_beechtree) | C++17 | 2000 ms | 19616 KB |
#include <bits/stdc++.h> using namespace std; vector<int> padre; vector<int>suma; vector<int>cc; bool menor_padre(int i, int j){ if(suma[cc[i]]!=suma[cc[j]]){ return suma[cc[i]]<suma[cc[j]]; } return i>j; } vector<int> beechtree(int n, int m, vector<int>P, vector<int>C){ vector<vector<int>> graph(n,vector<int>()); padre = P; cc=C; for(int i = 1; i < n; i++){ graph[P[i]].push_back(i); } vector<int> ans(n, 0); for(int i = 0; i < n; i++){ suma.assign(m,0); vector<int> sub; stack<int> pila; pila.push(i); while(!pila.empty()){ int nodo = pila.top(); pila.pop(); sub.push_back(nodo); suma[C[nodo]]++; sort(graph[nodo].begin(), graph[nodo].end(),menor_padre); for(int vecino : graph[nodo]){ pila.push(vecino); } } if(sub.size() == 1){ ans[i] = 1; continue; } bool bien = true; map<int, int> repeticiones; for(int j = 1; j < sub.size(); j++){ int color = C[sub[j]]; if(repeticiones.find(color) == repeticiones.end()){ repeticiones[color] = 0; } int expected_parent = sub[repeticiones[color]]; if(P[sub[j]] != expected_parent){ bien = false; break; } repeticiones[color]++; } if(bien){ ans[i] = 1; } } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 344 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Incorrect | 0 ms | 344 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Execution timed out | 2076 ms | 19616 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Incorrect | 0 ms | 348 KB | 2nd lines differ - on the 1st token, expected: '1', found: '0' |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Execution timed out | 2076 ms | 19616 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Incorrect | 0 ms | 344 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Incorrect | 0 ms | 344 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
11 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | 2nd lines differ - on the 2nd token, expected: '1', found: '0' |
3 | Halted | 0 ms | 0 KB | - |