Submission #1074756

# Submission time Handle Problem Language Result Execution time Memory
1074756 2024-08-25T13:46:59 Z Unforgettablepl Beech Tree (IOI23_beechtree) C++17
0 / 100
1 ms 428 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<int> ans(N);
    vector<vector<int>> adj(N);
    for(int i=1;i<N;i++)adj[P[i]].emplace_back(i);
    function<int(int)> dfs = [&](int x){
        vector<bool> contains(3);
        int state = -1;
        for(int&i:adj[x]) {
            if(contains[C[i]])return -2;
            contains[C[i]]=true;
            auto curr = dfs(i);
            if(curr==-2)return -2;
            if(curr==-1)continue;
            if(state!=-1 and state!=curr)return -2;
            state=curr;
        }
        if(contains[1] and !contains[2]) {
            if(state==2)return -2;
            state=1;
        }
        if(!contains[1] and contains[2]) {
            if(state==1)return -2;
            state=2;
        }
        ans[x]=1;
        return state;
    };
    dfs(0);
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 3rd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 0 ms 348 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 0 ms 348 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 428 KB 2nd lines differ - on the 3rd token, expected: '1', found: '0'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 3rd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 428 KB 2nd lines differ - on the 3rd token, expected: '1', found: '0'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 3rd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 428 KB 2nd lines differ - on the 3rd token, expected: '1', found: '0'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 3rd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -