답안 #1025934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1025934 2024-07-17T11:27:43 Z Gray 참나무 (IOI23_beechtree) C++17
8 / 100
84 ms 28500 KB
#include "beechtree.h"
#include <algorithm>
#include <iostream>
#include <map>

#define ll long long
#define ff first
#define ss second
#define ln "\n"
#define pll pair<ll, ll>
using namespace std;

vector<vector<ll>> A;
vector<int> col;
vector<int> lev;
ll n, m;
void dfs(ll u){
    lev[u]=1;
    for (auto v:A[u]){
        dfs(v);
        lev[u]=max(lev[v]+1, lev[u]);
    }
}

std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C)
{
    n=N; m=M;
    A.resize(n);
    lev.resize(n);
    col=C;
    for (ll i=1; i<n; i++){
        A[P[i]].push_back(i);
    }
    dfs(0);
    vector<int> pos(n, 1);
    for (ll i=0; i<n; i++){
        if (lev[i]>3) pos[i]=0;
        else if(lev[i]==1) pos[i]=1;
        else if (lev[i]==2){
            map<ll, ll> colus;
            for (auto v:A[i]) {
                if (colus[col[v]]) {pos[i]=0; break;}
                colus[col[v]]++;
            }
        }else{
            map<ll, ll> colus;
            for (auto v:A[i]) {
                if (colus[col[v]]) {pos[i]=0; break;}
                colus[col[v]]++;
            }
            if (!pos[i]) continue;
            ll cnt=0;
            for (auto v:A[i]){
                if (A[v].size()){
                    cnt++;
                    for (auto u:A[v]){
                        if (!colus[col[u]]) {pos[i]=0; break;}
                    }
                }
            }
            // cout << "H" << pos[i] << ln;
            if (cnt>1) pos[i]=0;
        }
    }
    return pos;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
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 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
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 Incorrect 1 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Incorrect 1 ms 344 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
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 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 62 ms 28500 KB Output is correct
6 Correct 54 ms 28500 KB Output is correct
7 Correct 1 ms 436 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 2 ms 448 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 64 ms 16468 KB Output is correct
12 Correct 84 ms 14252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
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 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 440 KB Output is correct
14 Correct 0 ms 436 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
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 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 440 KB Output is correct
14 Correct 0 ms 436 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB 2nd lines differ - on the 2nd token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -