답안 #1031575

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1031575 2024-07-23T01:12:04 Z aaaaaarroz 참나무 (IOI23_beechtree) C++17
컴파일 오류
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:15:22: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int> >::push(int&, int, int&)'
   15 |     q.push(b[xd],0,xd);
      |                      ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from beechtree.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:7: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note:   candidate expects 1 argument, 3 provided
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:31:29: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int> >::push(int&, std::vector<int>::size_type, int&)'
   31 |    q.push(b[u], -V.size(), u);
      |                             ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from beechtree.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:7: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; _Compare = std::less<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, int, int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note:   candidate expects 1 argument, 3 provided
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