제출 #1030473

#제출 시각아이디문제언어결과실행 시간메모리
1030473pcc도시들 (IOI15_towns)C++17
25 / 100
12 ms348 KiB
#include "towns.h" #include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,popcnt,sse4") using namespace std; const int mxn = 120; #define pii pair<int,int> #define fs first #define sc second int dp[mxn][mxn]; int ask(int a,int b){ if(a == b)return dp[a][b] = 0; if(dp[a][b] != -1)return dp[a][b]; else return dp[a][b] = dp[b][a] = getDistance(a,b); } int tocen(int a,int b,int c){ return ((ask(a,b)+ask(a,c)-ask(b,c))>>1); } int hubDistance(int N, int sub) { memset(dp,-1,sizeof(dp)); int ans = 1e9; int s = 0,e = 0; for(int i = 1;i<N;i++){ if(ask(s,i)>ask(s,e))e = i; } s = e; for(int i = 0;i<N;i++){ if(i == s)continue; if(ask(s,i)>ask(s,e))e = i; } vector<pii> v; int len = ask(s,e); cerr<<"[s,e]: "<<s<<' '<<e<<endl; for(int i = 0;i<N;i++){ if(i == s||i == e)continue; int d1 = tocen(s,i,e); int d2 = tocen(e,i,s); assert(d1+d2 == len); int d3 = tocen(i,s,e); v.push_back(pii(d1,d3)); } sort(v.begin(),v.end()); vector<pii> vv; for(auto &i:v){ if(!vv.empty()&&vv.back().fs == i.fs)vv.back().sc = max(vv.back().sc,i.sc); else vv.push_back(i); } v.swap(vv); //cerr<<s<<' '<<e<<":";for(auto &j:v)cerr<<j.fs<<','<<j.sc<<' ';cerr<<endl; vector<int> mx(v.size(),0); int pref = 0; for(int i = 0;i<v.size();i++){ mx[i] = max({mx[i],v[i].sc,v[i].fs+pref}); pref = max(pref,-v[i].fs+v[i].sc); } int suf = len; for(int i = (int)v.size()-1;i>=0;i--){ mx[i] = max({mx[i],suf-v[i].fs,v[i].sc}); suf = max(suf,v[i].fs+v[i].sc); } ans = min(ans,*min_element(mx.begin(),mx.end())); //cerr<<s<<' '<<e<<":"<<ans<<endl; return -ans; }

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

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:57:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |  for(int i = 0;i<v.size();i++){
      |                ~^~~~~~~~~
towns.cpp:24:28: warning: unused parameter 'sub' [-Wunused-parameter]
   24 | int hubDistance(int N, int sub) {
      |                        ~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...