제출 #281875

#제출 시각아이디문제언어결과실행 시간메모리
281875PKhing경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include "race.h" #include<bits/stdc++.h> #define FOR(i,a) for(int i=0;i<a;i++) #define FOR1(i,a) for(int i=1;i<=a;i++) #define db(a) printf("<%d> ",a) #define f first #define s second #define all(x) x.begin(),x.end() #define mp make_pair #define pb emplace_back #define p emplace #define ii pair<int,int> #define ll long long #define rf() freopen("_working/input.in","r",stdin) #define pf() freopen("_working/output.out","w+",stdout) using namespace std; const int INF=1e9; int size[200005]; queue<ii> len; set<ii> edge[200005]; int ans = INF; int centroid(int u,int p,int n){ for(auto v:edge[u]){ if(v.f!=p && size[v.f]>n/2)return centroid(v.f,u,n); } return u; } void dfs(int u,int p){ size[u]=1; for(auto v:edge[u]){ if(v.f!=p){ dfs(v.f,u); size[u]+=size[v.f]; } } } void setlen(int u,int p,int l,int cnt,int cen){ if(l>1000000)return; len.p(l,cnt); for(auto v:edge[u]){ if(v.f!=p){ setlen(v.f,u,l+v.s,cnt+1,cen); } } } int k; int decomp(int u,int p){ set<ii> f,tmp; dfs(u,-1); int x = centroid(u,-1,size[u]); for(auto v:edge[x]){ setlen(v.f,x,v.s,1,x); while(!len.empty()){ tmp.p(len.front()); auto x = f.upper_bound(mp(k-len.front().f,-1)); if(x->f == k-len.front().f)ans = min(ans,x->s+len.front().s); len.pop(); } for(auto i:tmp){ f.insert(i); } tmp.clear(); } for(auto v:edge[x]){ edge[v.f].erase(mp(x,v.s)); decomp(v.f,x); } edge[x].clear(); return x; } int best_path(int N, int K, int H[][2], int L[]) { k=K; for(int i=0;i<N-1;i++){ edge[H[i][0]].p(H[i][1],L[i]); edge[H[i][1]].p(H[i][0],L[i]); } decomp(0,-1); return ans==1e9?-1:ans; }#include "race.h" #include<bits/stdc++.h> #define FOR(i,a) for(int i=0;i<a;i++) #define FOR1(i,a) for(int i=1;i<=a;i++) #define db(a) printf("<%d> ",a) #define f first #define s second #define all(x) x.begin(),x.end() #define mp make_pair #define pb emplace_back #define p emplace #define ii pair<int,int> #define ll long long #define rf() freopen("_working/input.in","r",stdin) #define pf() freopen("_working/output.out","w+",stdout) using namespace std; const int INF=1e9; int size[200005]; queue<ii> len; set<ii> edge[200005]; int ans = INF; int centroid(int u,int p,int n){ for(auto v:edge[u]){ if(v.f!=p && size[v.f]>n/2)return centroid(v.f,u,n); } return u; } void dfs(int u,int p){ size[u]=1; for(auto v:edge[u]){ if(v.f!=p){ dfs(v.f,u); size[u]+=size[v.f]; } } } void setlen(int u,int p,int l,int cnt,int cen){ if(l>1000000)return; len.p(l,cnt); for(auto v:edge[u]){ if(v.f!=p){ setlen(v.f,u,l+v.s,cnt+1,cen); } } } int k; int decomp(int u,int p){ set<ii> f,tmp; dfs(u,-1); int x = centroid(u,-1,size[u]); for(auto v:edge[x]){ setlen(v.f,x,v.s,1,x); while(!len.empty()){ tmp.p(len.front()); auto x = f.upper_bound(mp(k-len.front().f,-1)); if(x->f == k-len.front().f)ans = min(ans,x->s+len.front().s); len.pop(); } for(auto i:tmp){ f.insert(i); } tmp.clear(); } for(auto v:edge[x]){ edge[v.f].erase(mp(x,v.s)); decomp(v.f,x); } edge[x].clear(); return x; } int best_path(int N, int K, int H[][2], int L[]) { k=K; for(int i=0;i<N-1;i++){ edge[H[i][0]].p(H[i][1],L[i]); edge[H[i][1]].p(H[i][0],L[i]); } decomp(0,-1); return ans==1e9?-1:ans; }

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

race.cpp:80:2: error: stray '#' in program
   80 | }#include "race.h"
      |  ^
race.cpp:80:3: error: 'include' does not name a type
   80 | }#include "race.h"
      |   ^~~~~~~
race.cpp:96:11: error: redefinition of 'const int INF'
   96 | const int INF=1e9;
      |           ^~~
race.cpp:17:11: note: 'const int INF' previously defined here
   17 | const int INF=1e9;
      |           ^~~
race.cpp:97:5: error: redefinition of 'int size [200005]'
   97 | int size[200005];
      |     ^~~~
race.cpp:18:5: note: 'int size [200005]' previously declared here
   18 | int size[200005];
      |     ^~~~
race.cpp:98:11: error: redefinition of 'std::queue<std::pair<int, int> > len'
   98 | queue<ii> len;
      |           ^~~
race.cpp:19:11: note: 'std::queue<std::pair<int, int> > len' previously declared here
   19 | queue<ii> len;
      |           ^~~
race.cpp:99:9: error: redefinition of 'std::set<std::pair<int, int> > edge [200005]'
   99 | set<ii> edge[200005];
      |         ^~~~
race.cpp:20:9: note: 'std::set<std::pair<int, int> > edge [200005]' previously declared here
   20 | set<ii> edge[200005];
      |         ^~~~
race.cpp:100:5: error: redefinition of 'int ans'
  100 | int ans = INF;
      |     ^~~
race.cpp:21:5: note: 'int ans' previously defined here
   21 | int ans = INF;
      |     ^~~
race.cpp:101:5: error: redefinition of 'int centroid(int, int, int)'
  101 | int centroid(int u,int p,int n){
      |     ^~~~~~~~
race.cpp:22:5: note: 'int centroid(int, int, int)' previously defined here
   22 | int centroid(int u,int p,int n){
      |     ^~~~~~~~
race.cpp:107:6: error: redefinition of 'void dfs(int, int)'
  107 | void dfs(int u,int p){
      |      ^~~
race.cpp:28:6: note: 'void dfs(int, int)' previously defined here
   28 | void dfs(int u,int p){
      |      ^~~
race.cpp:116:6: error: redefinition of 'void setlen(int, int, int, int, int)'
  116 | void setlen(int u,int p,int l,int cnt,int cen){
      |      ^~~~~~
race.cpp:37:6: note: 'void setlen(int, int, int, int, int)' previously defined here
   37 | void setlen(int u,int p,int l,int cnt,int cen){
      |      ^~~~~~
race.cpp:125:5: error: redefinition of 'int k'
  125 | int k;
      |     ^
race.cpp:46:5: note: 'int k' previously declared here
   46 | int k;
      |     ^
race.cpp:126:5: error: redefinition of 'int decomp(int, int)'
  126 | int decomp(int u,int p){
      |     ^~~~~~
race.cpp:47:5: note: 'int decomp(int, int)' previously defined here
   47 | int decomp(int u,int p){
      |     ^~~~~~
race.cpp:150:5: error: redefinition of 'int best_path(int, int, int (*)[2], int*)'
  150 | int best_path(int N, int K, int H[][2], int L[])
      |     ^~~~~~~~~
race.cpp:71:5: note: 'int best_path(int, int, int (*)[2], int*)' previously defined here
   71 | int best_path(int N, int K, int H[][2], int L[])
      |     ^~~~~~~~~