Submission #1074780

# Submission time Handle Problem Language Result Execution time Memory
1074780 2024-08-25T13:56:15 Z Unforgettablepl Beech Tree (IOI23_beechtree) C++17
0 / 100
50 ms 33188 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<pair<int,int>(int)> dfs = [&](int x)->pair<int,int>{
        vector<bool> contains(3);
        int state = -1;
        bool works = true;
        int maxsize = 0;
        for(int&i:adj[x]) {
            if(contains[C[i]]) {
                works=false;
            }
            contains[C[i]]=true;
            auto [curr,st] = dfs(i);
            maxsize=max(st,maxsize);
            if(curr==-2) {
                works = false;
                continue;
            }
            if(curr==-1)continue;
            if(state!=-1 and state!=curr) {
                works=false;
                continue;
            }
            state=curr;
        }
        if(contains[1] and !contains[2]) {
            if(state==2)return {-2,max(maxsize,(int)adj[x].size())};
            state=1;
        }
        if(!contains[1] and contains[2]) {
            if(state==1)return {-2,max(maxsize,(int)adj[x].size())};
            state=2;
        }
        if(maxsize>adj[x].size())works=false;
        if(!works)return {-2,max(maxsize,(int)adj[x].size())};
        ans[x]=1;
        return {state,max(maxsize,(int)adj[x].size())};
    };
    dfs(0);
    return ans;
}

Compilation message

beechtree.cpp: In lambda function:
beechtree.cpp:40:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         if(maxsize>adj[x].size())works=false;
      |            ~~~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Runtime error 1 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 1 ms 604 KB Output is correct
3 Runtime error 1 ms 348 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 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 1 ms 604 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Runtime error 50 ms 33188 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 348 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 -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 348 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 -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 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 -