제출 #60647

#제출 시각아이디문제언어결과실행 시간메모리
60647reality도시들 (IOI15_towns)C++17
36 / 100
43 ms980 KiB
#include "towns.h" #include "bits/stdc++.h" using namespace std; #define fi first #define se second #define ll long long #define dbg(v) cerr<<#v<<" = "<<v<<'\n' #define vi vector<int> #define vl vector <ll> #define pii pair<int,int> #define mp make_pair #define db long double #define pb push_back #define all(s) s.begin(),s.end() template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;} template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;} const int N = 256; int D[N][N]; int get(int x,int y) { if (D[x][y] != -1) return D[x][y]; return D[x][y] = D[y][x] = getDistance(x,y); } int hubDistance(int n, int sub) { srand(time(0)); const int root = rand() % n; memset(D,-1,sizeof(D)); int x = 0; for (int i = 0;i < n;++i) D[i][i] = 0; for (int i = 0;i < n;++i) if (get(root,i) > get(root,x)) x = i; int y = x; for (int i = 0;i < n;++i) if (get(x,i) > get(x,y)) y = i; vi s; for (int k = 0;k < n;++k) s.pb((get(root,x) - get(root,k) + get(x,k)) / 2); sort(all(s)); int dist = -1; int ans = 2e9; for (auto it : s) smin(ans,max(it,get(x,y) - it)); for (auto it : s) if (max(it,get(x,y) - it) == ans) dist = it; int a = 0,b = 0; vi was(n,0); for (int k = 0;k < n;++k) { int df = get(x,k) - get(root,k); int sm = get(root,x); if (df + sm < 2 * dist) was[k] = 1,++a; else if (df + sm > 2 * dist) was[k] = 1,++b; } if (max(a,b) > (n / 2)) return -ans; vi v; auto ok = [&](int A,int B) { return get(A,B) != get(A,x) + get(B,x) - 2 * dist; }; for (int i = 0;i < n;++i) if (!was[i]) { was[i] = 1; int cnt = 1; for (int j = i + 1;cnt <= (n / 2) && j < n;++j) if (!was[j] && ok(i,j)) ++cnt,was[j] = 1; if (cnt > (n / 2)) return -ans; } return ans; }

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

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:29:12: warning: conversion to 'unsigned int' from 'time_t {aka long int}' may alter its value [-Wconversion]
  srand(time(0));
        ~~~~^~~
towns.cpp:28:28: warning: unused parameter 'sub' [-Wunused-parameter]
 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...