Submission #1031576

# Submission time Handle Problem Language Result Execution time Memory
1031576 2024-07-23T01:12:38 Z aaaaaarroz Beech Tree (IOI23_beechtree) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "beechtree.h"
using namespace std;
const int MN=2e5+5;
int n, m;
vector<int> v[MN], p, c, ans;
int a[MN], b[MN];
void dfs(int xd=0){
    b[xd]=1;
    for (int &u: v[xd]){
        dfs(u);
        b[xd]+=b[u];
    }
    priority_queue<tuple<int, int, int>> q;
    q.push({b[xd],0,xd});
    vector<int> V;
    for(int i=0;i<=m;i++){
		a[i]=0;
	}
    while(!q.empty()){
        auto x=get<2>(q.top()); 
		q.pop(); 
        if (x!=xd) {
            if(a[c[x]]>=V.size() || V[a[c[x]]]!=p[x]){
				return;
			}
            a[c[x]]++;
        } 
        V.push_back(x);
        for(int u:v[x]){
			q.push({b[u], -V.size(), u});
		}
    }
    ans[xd]=1;
    return;
}
vector<int> beechtree(int N, int M, vector<int> P, vector<int> C){
    n=N;
	m=M; 
	p=P; 
	c=C;
	ans.resize(n,0);  
    for(int i=1,i<n;i++){
		v[p[i]].push_back(i);
	}
    dfs();
    return ans;
}

Compilation message

beechtree.cpp: In function 'void dfs(int)':
beechtree.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |             if(a[c[x]]>=V.size() || V[a[c[x]]]!=p[x]){
      |                ~~~~~~~^~~~~~~~~~
beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:43:18: error: expected ';' before '<' token
   43 |     for(int i=1,i<n;i++){
      |                  ^
      |                  ;
beechtree.cpp:43:18: error: expected primary-expression before '<' token