답안 #1039029

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1039029 2024-07-30T11:03:28 Z Zicrus 참나무 (IOI23_beechtree) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#include "beechtree.h"
using namespace std;

typedef long long ll;

vector<int> beechtree(int n, int m, vector<int> p, vector<int> c) {
    vector<int> res(n, 1);
    vector<vector<ll>> adj(n);
    for (int i = 1; i < n; i++) {
        adj[p[i]].push_back(i);
    }
    vector<pair<ll, ll>> szId(n);
    for (int i = 0; i < n; i++) {
        szId[i] = {adj[i].size(), i};
    }
    sort(szId.begin(), szId.end());
    unordered_set<ll> used;
    if (szId.back().second != 0) res[0] = 0;
    for (auto &e : adj[0]) {
        if (used.count(c[e]))
            res[0] = 0;
        used.insert(c[e]);
    }
    for (int i = n-2; i >= 1; i--) {
        unordered_set<ll> nw;
        for (auto &e : adj[szId[i].second]) {
            if (!used.count(c[e]))
                res[0] = 0;
            if (nw.count(c[e]))
                res[szId[i].second] = res[0] = 0;
            nw.insert(c[e]);
        }
        used = nw;
    }
    return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 15th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -