제출 #253737

#제출 시각아이디문제언어결과실행 시간메모리
253737khangalSplit the Attractions (IOI19_split)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
#define po pop_back
#define pb push_back
#define mk make_pair
#define lw lower_bound
#define up upper_bound
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MAX 1e18
#define MIN -1e18
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define per(i,a,b) for(ll i=b;i>=a;i--)
#define con continue
#define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628
// typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// template< typename T>
// using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll sz,n,m,ans,mid,mn,mx,cnt,T,sum,h1,h2,e[1234567],b[1234567],c[1234567],d[1<<20],k,i,j,l,r,h,a[1234567],w,x,y,z;
bool used[1234567];
vector<int> v[1234567],vec,vv1,vv2;
string s1,s;
int sz[1234567],par[1234567];
ll dx[4]={-1,1,0,0},dy[4]={0,0,-1,1},c1[123][123];
void dfs(int node , int p){
    if(sz[node] > 0) return 0;
    par[node] = p;
    sz[node] = 1;
    for(auto x : v[node]) sz[node] += dfs(x , node);
    return sz[node];
}
void dfs1(int node){
    used[node] = 1;
    vv1.pb(node);
    for(auto x : v[node]) if(par[x] == node) dfs1(x);
    return;
}
void dfs2(int node){
    if(used[node]) return;
    vv2.pb(node);
    for(auto x : v[node]) if(par[x] == node) dfs2(x);
    return;
}
vector<int> find_split(int n ,  int  a , int b ,int c  ,vector<int>v1 , vector<int>v2){
    int m = v1.size();
    for(int i=0; i<m; i++){
        v[v2[i]].pb(v1[i]);
        v[v1[i]].pb(v2[i]);
    }
    dfs(0);
    vector<pair<int , int>> vv = {{a, 1}, {b, 2}, {c, 3}};
    sort(vv.begin(), vv.end());
    vector<int> ans(n, 0);
    for(int i=0; i<n; i++){
        if(sz[i] >= vv[0].ff && n-sz[i] >= vv[1].ff){
            dfs1(i);
            dfs2(0);
            for(int j=0; j<vv1.size(); j++){
                if(j < vv[0].ff) ans[vv1[j]] = vv[0].ss;
                else ans[vv1[j]] = vv[2].ss;
            }
            for(int j=0; j<vv2.size(); j++){
                if(j < vv[1].ff) ans[vv2[j]] = vv[1].ss;
                else ans[vv2[j]] = vv[2].ss;
            }
            return ans;
        } 
        else 
            if(sz[i] >= vv[1].ff && n-sz[i] >= vv[0].ff){
                dfs1(i);
                dfs2(0);
                for(int j=0; j<vv1.size(); j++){
                    if(j < vv[1].ff) ans[vv1[j]] = vv[1].ss;
                    else ans[vv1[j]] = vv[2].ss;
                }
                for(int j=0; j<vv2.size(); j++){
                    if(j < vv[0].ff) ans[vv2[j]] = vv[0].ss;
                    else ans[vv2[j]] = vv[2].ss;
            }
            return ans;
        }
    }
}

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

split.cpp:29:15: error: conflicting declaration 'int sz [1234567]'
 int sz[1234567],par[1234567];
               ^
split.cpp:25:4: note: previous declaration as 'll sz'
 ll sz,n,m,ans,mid,mn,mx,cnt,T,sum,h1,h2,e[1234567],b[1234567],c[1234567],d[1<<20],k,i,j,l,r,h,a[1234567],w,x,y,z;
    ^~
split.cpp: In function 'void dfs(int, int)':
split.cpp:32:15: error: invalid types 'll {aka long long int}[int]' for array subscript
     if(sz[node] > 0) return 0;
               ^
split.cpp:32:29: error: return-statement with a value, in function returning 'void' [-fpermissive]
     if(sz[node] > 0) return 0;
                             ^
split.cpp:34:12: error: invalid types 'll {aka long long int}[int]' for array subscript
     sz[node] = 1;
            ^
split.cpp:35:34: error: invalid types 'll {aka long long int}[int]' for array subscript
     for(auto x : v[node]) sz[node] += dfs(x , node);
                                  ^
split.cpp:36:19: error: invalid types 'll {aka long long int}[int]' for array subscript
     return sz[node];
                   ^
split.cpp:36:19: error: return-statement with a value, in function returning 'void' [-fpermissive]
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:56:10: error: too few arguments to function 'void dfs(int, int)'
     dfs(0);
          ^
split.cpp:31:6: note: declared here
 void dfs(int node , int p){
      ^~~
split.cpp:61:16: error: invalid types 'll {aka long long int}[int]' for array subscript
         if(sz[i] >= vv[0].ff && n-sz[i] >= vv[1].ff){
                ^
split.cpp:61:39: error: invalid types 'll {aka long long int}[int]' for array subscript
         if(sz[i] >= vv[0].ff && n-sz[i] >= vv[1].ff){
                                       ^
split.cpp:64:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j=0; j<vv1.size(); j++){
                          ~^~~~~~~~~~~
split.cpp:68:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j=0; j<vv2.size(); j++){
                          ~^~~~~~~~~~~
split.cpp:75:20: error: invalid types 'll {aka long long int}[int]' for array subscript
             if(sz[i] >= vv[1].ff && n-sz[i] >= vv[0].ff){
                    ^
split.cpp:75:43: error: invalid types 'll {aka long long int}[int]' for array subscript
             if(sz[i] >= vv[1].ff && n-sz[i] >= vv[0].ff){
                                           ^
split.cpp:78:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int j=0; j<vv1.size(); j++){
                              ~^~~~~~~~~~~
split.cpp:82:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int j=0; j<vv2.size(); j++){
                              ~^~~~~~~~~~~
split.cpp:89:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^