제출 #210985

#제출 시각아이디문제언어결과실행 시간메모리
210985autumn_eel도시들 (IOI15_towns)C++14
48 / 100
29 ms512 KiB
#include "towns.h" #include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; int d[150][150]; int dist(int i,int j){ if(i==j)return 0; if(i>j)swap(i,j); if(d[i][j]!=-1)return d[i][j]; int x=getDistance(i,j); return d[i][j]=x; } int hubDistance(int N, int sub) { memset(d,-1,sizeof(d)); int Max=0,s=-1; rep(i,N){ if(Max<dist(0,i)){ Max=dist(0,i); s=i; } } Max=0;int t=-1; rep(i,N){ if(Max<dist(s,i)){ Max=dist(s,i); t=i; } } int Min=INT_MAX; set<int>idx; map<int,vector<int>>mp; rep(i,N){ int x=dist(s,i),y=dist(t,i); int z=(x+y-Max)/2; int a=x-z,b=y-z; mp[a].push_back(i); if(Min>max(a,b)){ Min=max(a,b); idx.clear(); } if(Min==max(a,b)){ idx.insert(a); } } if(sub<=2)return Min; auto C=[&](int id){ int c1=0,c2=0; for(auto p:mp){ if(p.first<id)c1+=p.second.size(); if(p.first>id)c2+=p.second.size(); } if(c1>N/2||c2>N/2)return false; random_device rnd; shuffle(mp[id].begin(),mp[id].end(),rnd); vector<vector<int>>vs; for(int v:mp[id]){ bool flag=false; sort(vs.begin(),vs.end(),[](vector<int>&a,vector<int>&b){ return a.size()>b.size(); }); for(auto&V:vs){ if(dist(s,V[0])+dist(s,v)-2*id!=dist(V[0],v)){ V.push_back(v);flag=true; if(V.size()>N/2)return false; break; } } if(!flag)vs.push_back({v}); } return true; }; for(int id:idx){ if(C(id))return Min; } return -Min; }

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

towns.cpp: In lambda function:
towns.cpp:51:36: warning: conversion to 'int' from 'std::vector<int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
    if(p.first<id)c1+=p.second.size();
                                    ^
towns.cpp:52:36: warning: conversion to 'int' from 'std::vector<int>::size_type {aka long unsigned int}' may alter its value [-Wconversion]
    if(p.first>id)c2+=p.second.size();
                                    ^
towns.cpp:66:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      if(V.size()>N/2)return false;
         ~~~~~~~~^~~~
#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...