제출 #1229722

#제출 시각아이디문제언어결과실행 시간메모리
1229722virgoliny참나무 (IOI23_beechtree)C++20
컴파일 에러
0 ms0 KiB
#include "beechtree.h"
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define vll vector<ll>
#define sd second
#define ft first
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define pll pair<ll, ll>
#define mod 1000000007
#define _set tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update>
#define inf (ll)1e15
#define db(x) cout<<#x<<" : "<<x<<endl;
#define PRESICION(x) cout.setf(ios::fixed,ios::floatfield); cout.precision(x);
using namespace std;
using namespace __gnu_pbds;
ll dx[]={1, -1, 0, 0};
ll dy[]={0, 0, 1, -1};
inline ll sm(ll a, ll b){
return ((a%mod)+(b%mod))%mod;
}
inline ll ml(ll a, ll b){
return ((a%mod)*(b%mod))%mod;
}
inline ll rs(ll a, ll b){
return ((a%mod)-(b%mod)+mod)%mod;
}
ll bpow(ll a , ll b) {
if (b==0)return 1;
if (b%2!=0)return ((bpow(a, b-1)%mod)*(a%mod))%mod;
ll r=bpow (a ,b/ 2) ;
return ((r%mod)*(r%mod))%mod;
}
vector<vector<ll>> res, adj;
inline void dfs(ll n, ll p){
//db(n)
res[n].push_back(n);
for(auto y: adj[n]){
if(y==p)continue;
res.push_back()
}
for(auto y: adj[n]){
if(y==p)continue;
dfs(y, n);
for(auto x: res[y])res[n].push_back(x);
}
}
inline bool check(vector<int>& C, vector<int>& P, vector<ll>& v1){
vector<ll> v(501, 0);
bool n=1;
for(int i=1; i<v1.size(); i++){
if(v1[v[C[v1[i]]]]!=P[v1[i]])n=0;
v[C[v1[i]]]++;
}
return n;
}
std::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C){
    vector<int> res1(N, 0);
    vector<bool> res2(N, 0);
    vector<vector<ll>>().swap(adj);
    vector<vector<ll>>().swap(res);
    adj.resize(N+1);
    res.resize(N+1);
    ll o=-1;
    for(int i=1; i<N; i++){o=min(o, C[i]*1LL);}
    for(int i=1; i<N; i++){
    if(C[i]==o)C[i]=1;
    else C[i]=2;
    }
    for(int i=1; i<N; i++){
    adj[P[i]].push_back(i);
    if(C[i]==1)res2[P[i]]=1;
    if(C[i]==2)res3[P[i]]=1;
    }
    dfs(0, 0);
    set<ll> s;
    for(int i=0; i<N; i++){
    set<ll>.swap(s);
    for(auto y: adj[i])s.insert(C[y]);
    ll o=s.size(), o1=adj[i].size();
    if(o==o1)res2[i]=1;
    }
    for(int i=0; i<N; i++){
    ll o=0;
    bool n1=1;
    for(auto y: adj[i]){
    if(!adj[y].empty())o1++;
    if(!adj[y].empty() && res2[y]==0)n1=0;
    }
    if(n1 && o<=1)res1[i]=1;
    }
    return res1;
}

컴파일 시 표준 에러 (stderr) 메시지

beechtree.cpp: In function 'void dfs(ll, ll)':
beechtree.cpp:45:14: error: no matching function for call to 'std::vector<std::vector<long long int> >::push_back()'
   45 | res.push_back()
      | ~~~~~~~~~~~~~^~
In file included from /usr/include/c++/11/vector:67,
                 from beechtree.h:1,
                 from beechtree.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<long long int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/11/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<long long int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1203:7: note:   candidate expects 1 argument, 0 provided
beechtree.cpp: In function 'std::vector<int> beechtree(int, int, std::vector<int>, std::vector<int>)':
beechtree.cpp:78:16: error: 'res3' was not declared in this scope; did you mean 'res2'?
   78 |     if(C[i]==2)res3[P[i]]=1;
      |                ^~~~
      |                res2
beechtree.cpp:83:12: error: expected unqualified-id before '.' token
   83 |     set<ll>.swap(s);
      |            ^
beechtree.cpp:92:24: error: 'o1' was not declared in this scope; did you mean 'n1'?
   92 |     if(!adj[y].empty())o1++;
      |                        ^~
      |                        n1