답안 #1067706

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067706 2024-08-21T01:18:17 Z vjudge1 참나무 (IOI23_beechtree) C++17
0 / 100
10 ms 19804 KB
#include "beechtree.h"
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp[200100];
vector<int>par,col;
int dep[200100];
vector<int>sub[200100],adj[200100];
int check(vector<int>v){
    map<int,int>mp;
    for(int i=1;i<v.size();i++)
        if(v[mp[col[v[i]]]++]!=par[v[i]])
            return 0;
    return 1;
}
int checkdep2(vector<int>nods){
    sort(nods.begin(),nods.end(),[](int a,int b){
        return sub[a].size()>sub[b].size();
    });

    vector<int>otherstuf;
    while(sub[nods.back()].size()==1)
        otherstuf.push_back(nods.back()),
        nods.pop_back();
    for(int i=0;i<nods.size();i++)
        for(auto K:adj[i])
            if(sub[K].size()==1)
                nods.push_back(K);
    return check(nods);
}

vector<int> beechtree(int N, int M, vector<int> P, vector<int> C){
    par=P;
    col=C;
    vector<int> V(N,1);
    for(int i=1;i<N;i++)
        if(mp[P[i]][C[i]]++)
            V[P[i]]=0,V[P[i]?P[P[i]]:P[i]]=0;
    for(int i=N;--i;)
        dep[par[i]]=max(dep[par[i]],++dep[i]);
    for(int i=N;i--;){
        sub[i].push_back(i);
        if(P[i]>=0)
            for(auto d:sub[i])
                sub[P[i]].push_back(d);
    }
    dep[0]++;
    vector<int>VV(N);
    iota(VV.begin(),VV.end(),0);
    if(V[0]==1)
        V[0]=checkdep2(VV);
    return V;
}

Compilation message

beechtree.cpp: In function 'int check(std::vector<int>)':
beechtree.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=1;i<v.size();i++)
      |                 ~^~~~~~~~~
beechtree.cpp: In function 'int checkdep2(std::vector<int>)':
beechtree.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i=0;i<nods.size();i++)
      |                 ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 19800 KB Output is correct
2 Incorrect 7 ms 19804 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 19800 KB Output is correct
2 Incorrect 10 ms 19804 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 19800 KB Output is correct
2 Incorrect 10 ms 19804 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 19800 KB Output is correct
2 Correct 8 ms 19804 KB Output is correct
3 Incorrect 6 ms 19804 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 19800 KB Output is correct
2 Incorrect 10 ms 19804 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 19800 KB Output is correct
2 Incorrect 7 ms 19804 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 19800 KB Output is correct
2 Incorrect 10 ms 19804 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 19800 KB Output is correct
2 Incorrect 7 ms 19804 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 19800 KB Output is correct
2 Incorrect 10 ms 19804 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 19800 KB Output is correct
2 Incorrect 7 ms 19804 KB 2nd lines differ - on the 1st token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -