제출 #387446

#제출 시각아이디문제언어결과실행 시간메모리
387446mehrdad_sohrabi도시들 (IOI15_towns)C++14
컴파일 에러
0 ms0 KiB
/// Black lives matter #include <bits/stdc++.h> //#include "towns.h" /// 500 485 462 A4 using namespace std; typedef long long int ll; typedef complex<double> point; typedef long double ld; #define pb push_back #define pii pair < ll , ll > #define F first #define S second //#define endl '\n' #define int long long #define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") #define kill(x) return cout<<x<<'\n', 0; const int N=200; /* ll disin[N][N]; int getDistance(ll u,ll v){ return disin[u][v]; } */ ll dis[N][N]; ll t[3]; int32_t hubDistance(int32_t n, int32_t sub) { memset(t,0,sizeof t); ll mx0=0,id0=0,mx1=0,id1=0; memset(dis,-1,sizeof dis); for (int i=1;i<n;i++){ if (dis[0][i]==-1) dis[0][i]=getDistance(0,i),dis[i][0]=dis[0][i]; if (dis[0][i]>mx0){ mx0=dis[0][i]; id0=i; } } for (int i=0;i<n;i++){ if (dis[id0][i]==-1) dis[id0][i]=getDistance(id0,i),dis[i][id0]=dis[id0][i]; if (dis[id0][i]>mx1){ mx1=dis[id0][i]; id1=i; } } ll ans=dis[id0][id1],mn=1e9,rast=0; t[0]++; t[2]++; for (int i=0;i<n;i++){ if (i==id0 || i==id1) continue; dis[id1][i]=getDistance(id1,i); dis[i][id1]=dis[id1][i]; ll dd=dis[id0][i]-dis[id1][i]; ll z=abs(dis[id0][i]-dis[id1][i]); mn=min(mn,z); if (mn==z) rast=dd; } for (int i=0;i<n;i++){ if (i==id0 || i==id1) continue; ll dd=dis[id0][i]-dis[id1][i]; if (dd==rast) t[1]++; if (dd<rast) t[0]++; if (dd>rast) t[2]++; } ll zz=1; if (t[0]>n/2 || t[1]>n/2 || t[2]>n/2) zz=-1; return zz*(ans+mn)/2; } /* int32_t main(){ ll x,y; cin >> x >> y; ll n; cin >> n; for (int i=0;i<n;i++){ for (int j=0;j<n;j++) cin >> disin[i][j]; } cout << hubDistance(n,y); } */ /* 1 1 10 0 16 16 16 20 16 20 16 8 16 16 0 16 16 20 8 20 16 16 16 16 16 0 8 20 16 20 16 16 16 16 16 8 0 20 16 20 16 16 16 20 20 20 20 0 20 22 20 20 20 16 8 16 16 20 0 20 16 16 16 20 20 20 20 22 20 0 20 20 20 16 16 16 16 20 16 20 0 16 8 8 16 16 16 20 16 20 16 0 16 16 16 16 16 20 16 20 8 16 0 */

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

towns.cpp: In function 'int32_t hubDistance(int32_t, int32_t)':
towns.cpp:32:38: error: 'getDistance' was not declared in this scope; did you mean 'hubDistance'?
   32 |         if (dis[0][i]==-1) dis[0][i]=getDistance(0,i),dis[i][0]=dis[0][i];
      |                                      ^~~~~~~~~~~
      |                                      hubDistance
towns.cpp:39:42: error: 'getDistance' was not declared in this scope; did you mean 'hubDistance'?
   39 |         if (dis[id0][i]==-1) dis[id0][i]=getDistance(id0,i),dis[i][id0]=dis[id0][i];
      |                                          ^~~~~~~~~~~
      |                                          hubDistance
towns.cpp:50:21: error: 'getDistance' was not declared in this scope; did you mean 'hubDistance'?
   50 |         dis[id1][i]=getDistance(id1,i);
      |                     ^~~~~~~~~~~
      |                     hubDistance
towns.cpp:67:20: warning: conversion from 'll' {aka 'long long int'} to 'int32_t' {aka 'int'} may change value [-Wconversion]
   67 |  return zz*(ans+mn)/2;
      |         ~~~~~~~~~~~^~
towns.cpp:27:40: warning: unused parameter 'sub' [-Wunused-parameter]
   27 | int32_t hubDistance(int32_t n, int32_t sub) {
      |                                ~~~~~~~~^~~