Submission #1067707

# Submission time Handle Problem Language Result Execution time Memory
1067707 2024-08-21T01:22:51 Z vjudge1 Beech Tree (IOI23_beechtree) C++17
0 / 100
1996 ms 2097152 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;) adj[par[i]].push_back(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:23:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i=0;i<nods.size();i++)
      |                 ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 19804 KB Output is correct
2 Incorrect 6 ms 19804 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 19804 KB Output is correct
2 Correct 8 ms 19804 KB Output is correct
3 Correct 7 ms 19800 KB Output is correct
4 Correct 6 ms 19804 KB Output is correct
5 Incorrect 7 ms 19804 KB 2nd lines differ - on the 2nd token, expected: '0', found: '1'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 19804 KB Output is correct
2 Correct 8 ms 19804 KB Output is correct
3 Correct 7 ms 19800 KB Output is correct
4 Correct 6 ms 19804 KB Output is correct
5 Incorrect 7 ms 19804 KB 2nd lines differ - on the 2nd token, expected: '0', found: '1'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 19800 KB Output is correct
2 Correct 6 ms 19804 KB Output is correct
3 Correct 8 ms 19804 KB Output is correct
4 Correct 7 ms 19804 KB Output is correct
5 Correct 6 ms 19804 KB Output is correct
6 Correct 7 ms 19804 KB Output is correct
7 Correct 8 ms 20036 KB Output is correct
8 Correct 7 ms 19804 KB Output is correct
9 Incorrect 8 ms 19804 KB 2nd lines differ - on the 1st token, expected: '1', found: '0'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 19804 KB Output is correct
2 Correct 8 ms 19804 KB Output is correct
3 Correct 7 ms 20012 KB Output is correct
4 Correct 7 ms 19804 KB Output is correct
5 Runtime error 1996 ms 2097152 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 19804 KB Output is correct
2 Incorrect 6 ms 19804 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 19804 KB Output is correct
2 Correct 8 ms 19804 KB Output is correct
3 Correct 7 ms 20012 KB Output is correct
4 Correct 7 ms 19804 KB Output is correct
5 Correct 7 ms 19804 KB Output is correct
6 Correct 6 ms 19804 KB Output is correct
7 Correct 6 ms 19804 KB Output is correct
8 Correct 7 ms 19800 KB Output is correct
9 Correct 6 ms 19804 KB Output is correct
10 Correct 7 ms 19804 KB Output is correct
11 Correct 6 ms 19804 KB Output is correct
12 Correct 6 ms 19804 KB Output is correct
13 Correct 7 ms 19804 KB Output is correct
14 Correct 7 ms 19804 KB Output is correct
15 Correct 6 ms 19804 KB Output is correct
16 Correct 7 ms 19804 KB Output is correct
17 Correct 6 ms 20020 KB Output is correct
18 Incorrect 7 ms 19800 KB 2nd lines differ - on the 2nd token, expected: '0', found: '1'
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 19804 KB Output is correct
2 Incorrect 6 ms 19804 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 19804 KB Output is correct
2 Correct 8 ms 19804 KB Output is correct
3 Correct 7 ms 20012 KB Output is correct
4 Correct 7 ms 19804 KB Output is correct
5 Correct 7 ms 19804 KB Output is correct
6 Correct 6 ms 19804 KB Output is correct
7 Correct 6 ms 19804 KB Output is correct
8 Correct 7 ms 19800 KB Output is correct
9 Correct 6 ms 19804 KB Output is correct
10 Correct 7 ms 19804 KB Output is correct
11 Correct 6 ms 19804 KB Output is correct
12 Correct 6 ms 19804 KB Output is correct
13 Correct 7 ms 19804 KB Output is correct
14 Correct 7 ms 19804 KB Output is correct
15 Correct 6 ms 19804 KB Output is correct
16 Correct 7 ms 19804 KB Output is correct
17 Correct 6 ms 20020 KB Output is correct
18 Incorrect 7 ms 19800 KB 2nd lines differ - on the 2nd token, expected: '0', found: '1'
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 19804 KB Output is correct
2 Incorrect 6 ms 19804 KB 2nd lines differ - on the 4th token, expected: '0', found: '1'
3 Halted 0 ms 0 KB -