# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1031473 | 2024-07-22T21:26:02 Z | aaaaaarroz | 참나무 (IOI23_beechtree) | C++17 | 2000 ms | 19516 KB |
#include <bits/stdc++.h> using namespace std; vector<int> padre; vector<int> sub; bool menor_padre(int i, int j){ return sub[i] < sub[j]; } vector<int> beechtree(int n, int m, vector<int>P, vector<int>C){ vector<vector<int>> graph(n,vector<int>()); padre = P; 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++){ queue<int> cola; cola.push(i); while(!cola.empty()){ int nodo = cola.front(); cola.pop(); sub.push_back(nodo); for(int vecino : graph[nodo]){ cola.push(vecino); } } if(sub.size() == 1){ ans[i] = 1; continue; } sort(sub.begin() + 1, sub.end(), menor_padre); 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; } sub.clear(); } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | 2nd lines differ - on the 3rd token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 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 | Incorrect | 0 ms | 348 KB | 2nd lines differ - on the 3rd token, expected: '1', found: '0' |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 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 | Execution timed out | 2045 ms | 19516 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 2nd lines differ - on the 17th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | 2nd lines differ - on the 3rd token, expected: '1', found: '0' |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | 2nd lines differ - on the 3rd token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | 2nd lines differ - on the 3rd token, expected: '1', found: '0' |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | 2nd lines differ - on the 3rd token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | 2nd lines differ - on the 3rd token, expected: '1', found: '0' |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | 2nd lines differ - on the 3rd token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |