# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1004655 | 2024-06-21T11:33:28 Z | MilosMilutinovic | 참나무 (IOI23_beechtree) | C++17 | 2000 ms | 44832 KB |
#include "beechtree.h" #include <bits/stdc++.h> using namespace std; vector<int> beechtree(int n, int m, vector<int> p, vector<int> c) { vector<vector<int>> ch(n); for (int i = 1; i < n; i++) { ch[p[i]].push_back(i); } vector<vector<int>> my(n); for (int i = 0; i < n; i++) { for (int j : ch[i]) { my[i].push_back(c[j]); } } vector<bool> diff(n); for (int i = 0; i < n; i++) { set<int> st(my[i].begin(), my[i].end()); diff[i] = (st.size() == my[i].size()); } vector<int> tin(n); vector<int> tout(n); int T = 0; function<void(int)> Dfs = [&](int v) { tin[v] = ++T; for (int u : ch[v]) { Dfs(u); } tout[v] = T; }; Dfs(0); auto IsAnc = [&](int x, int y) { return tin[x] <= tin[y] && tout[y] <= tout[x]; }; auto IsSubset = [&](vector<int> a, vector<int> b) { set<int> st(a.begin(), a.end()); for (int i : b) { if (st.find(i) == st.end()) { return false; } } return true; }; auto NoIntersect = [&](vector<int> a, vector<int> b) { set<int> st; for (int i : a) { st.insert(i); } for (int i : b) { st.insert(i); } return st.size() == a.size() + b.size(); }; vector<int> res(n); for (int v = 0; v < n; v++) { bool ok = true; vector<int> ver; for (int i = 0; i < n; i++) { if (IsAnc(v, i)) { ver.push_back(i); } } for (int i : ver) { ok &= diff[i]; } for (int i : ver) { if (i == v) { continue; } ok &= IsSubset(my[p[i]], my[i]); } /* for (int i : ver) { for (int j : ver) { if (IsAnc(i, j) || IsAnc(j, i)) { continue; } ok &= NoIntersect(my[i], my[j]); } } */ res[v] = ok; } return res; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 360 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | 2nd lines differ - on the 1st token, expected: '0', found: '1' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 604 KB | Output is correct |
9 | Incorrect | 0 ms | 348 KB | 2nd lines differ - on the 1st token, expected: '0', found: '1' |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 2041 ms | 44832 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | 2nd lines differ - on the 1st token, expected: '0', found: '1' |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 604 KB | Output is correct |
5 | Execution timed out | 2041 ms | 44832 KB | Time limit exceeded |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 360 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | 2nd lines differ - on the 1st token, expected: '0', found: '1' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 604 KB | Output is correct |
5 | Incorrect | 0 ms | 348 KB | 2nd lines differ - on the 1st token, expected: '0', found: '1' |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 360 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | 2nd lines differ - on the 1st token, expected: '0', found: '1' |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 604 KB | Output is correct |
5 | Incorrect | 0 ms | 348 KB | 2nd lines differ - on the 1st token, expected: '0', found: '1' |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 360 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | 2nd lines differ - on the 1st token, expected: '0', found: '1' |
3 | Halted | 0 ms | 0 KB | - |