제출 #649909

#제출 시각아이디문제언어결과실행 시간메모리
649909KoalaMuch경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include "race.h" #include<iostream> #include<utility> #include<vector> #include<map> using namespace std; const long long N = 2e5+5; long long sz[N]; long long st[N]; long long ft[N]; long long ver[N]; long long orig_len[N]; long long orig_sum[N]; map<long long,long long> mem; vector<pair<long long,long long>> g[N]; long long t; long long ans = 1e10; void preprocess(long long u,long long len=0,long long sum=0,long long p = -1){ ++t; st[u] = t; ver[t] = u; orig_sum[u] = sum; orig_len[u] = len; sz[u] = 1; for(auto &x:g[u]){ if(x.first!=p){ preprocess(x.first,len+1,sum+x.second,u); sz[u]+=sz[x.first]; } } ft[u] = t; } void solve(long long u,long long target,long long p = -1,bool keep = false){ long long mx = -1,big_child = -1,del_sum = orig_sum[u],del_len = orig_len[u]; for(auto &x:g[u]) if(x.first!=p&&sz[x.first]>mx) mx = sz[x.first],big_child = x.first; for(auto &x:g[u]){ if(x.first!=p&&x.first!=big_child){ solve(x.first,target,u,false); } } if(big_child!=-1){ solve(big_child,target,u,true); } long long need = target-orig_sum[u]+2*del_sum; if(mem.find(need)!=mem.end()) ans = min(ans,mem[need]+orig_len[u]-2*del_len); if(mem.find(orig_sum[u])) mem[orig_sum[u]] = orig_len[u]; mem[orig_sum[u]] = min(mem[orig_sum[u]],orig_len[u]); for(auto &x:g[u]){ if(x.first!=p&&x.first!=big_child){ for(long long i=st[x.first];i<=ft[x.first];i++){ long long v = ver[i]; need = target-orig_sum[v]+2*del_sum; if(mem.find(need)) ans = min(ans,mem[need]+orig_len[v]-2*del_len); if(mem.find(orig_sum[v])) mem[orig_sum[v]] = orig_len[v]; mem[orig_sum[v]] = min(mem[orig_sum[v]],orig_len[v]); } } } if(!keep){ for(long long i=st[u];i<=ft[u];i++){ mem.erase(orig_sum[ver[i]]); } } } int best_path(int N, int K, int H[][2], int L[]) { for(long long i=0;i<N;i++) g[H[i][0]].push_back({H[i][1],L[i]}),g[H[i][1]].push_back({H[i][0],L[i]}); preprocess(0); solve(0,K); if(ans>=N) return -1; return ans; }

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

race.cpp: In function 'void solve(long long int, long long int, long long int, bool)':
race.cpp:46:16: error: could not convert 'mem.std::map<long long int, long long int>::find(orig_sum[u])' from 'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'} to 'bool'
   46 |     if(mem.find(orig_sum[u]))   mem[orig_sum[u]] = orig_len[u];
      |        ~~~~~~~~^~~~~~~~~~~~~
      |                |
      |                std::map<long long int, long long int>::iterator {aka std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator}
race.cpp:53:28: error: could not convert 'mem.std::map<long long int, long long int>::find(need)' from 'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'} to 'bool'
   53 |                 if(mem.find(need))  ans = min(ans,mem[need]+orig_len[v]-2*del_len);
      |                    ~~~~~~~~^~~~~~
      |                            |
      |                            std::map<long long int, long long int>::iterator {aka std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator}
race.cpp:54:28: error: could not convert 'mem.std::map<long long int, long long int>::find(orig_sum[v])' from 'std::map<long long int, long long int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator'} to 'bool'
   54 |                 if(mem.find(orig_sum[v]))   mem[orig_sum[v]] = orig_len[v];
      |                    ~~~~~~~~^~~~~~~~~~~~~
      |                            |
      |                            std::map<long long int, long long int>::iterator {aka std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::iterator}