제출 #387402

#제출 시각아이디문제언어결과실행 시간메모리
387402alishahali1382도시들 (IOI15_towns)C++14
컴파일 에러
0 ms0 KiB
#include "towns.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define debug(x) {cerr<<#x<<"="<<x<<"\n";} #define debugp(p) {cerr<<#p<<"={"<<p.first<<", "<<p.second<<"}\n";} #define debug2(x, y) {cerr<<#x<<", "<<#y<<" = "<<x<<", "<<y<<"\n";} #define pb push_back #define all(x) x.begin(), x.end() const int mod=1000000007; const int N=120; int n, m, k, ans; int D[N][N]; int ask(int i, int j){ if (i==j) return 0; if (i>j) swap(i, j); if (D[i][j]==-1) D[i][j]=getDistance(i, j); return D[i][j]; } int hubDistance(int n, int sub){ memset(D, -1, sizeof(D)); int X=0, Y=0; for (int i=1; i<n; i++) if (ask(0, i)>ask(0, X)) X=i; for (int i=1; i<n; i++) if (ask(X, i)>ask(X, Y)) Y=i; ans=inf; for (int i=0; i<n; i++){ int a=(ask(X, i)+ask(X, Y)-ask(Y, i))/2; int b=ask(X, Y)-a, c=ask(X, i)-a; ans=min(ans, max(a, b)); } return ans; }

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

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:26:31: warning: declaration of 'n' shadows a global declaration [-Wshadow]
   26 | int hubDistance(int n, int sub){
      |                               ^
towns.cpp:16:5: note: shadowed declaration is here
   16 | int n, m, k, ans;
      |     ^
towns.cpp:31:6: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   31 |  ans=inf;
      |      ^~~
      |      ynf
towns.cpp:34:22: warning: unused variable 'c' [-Wunused-variable]
   34 |   int b=ask(X, Y)-a, c=ask(X, i)-a;
      |                      ^
towns.cpp:26:28: warning: unused parameter 'sub' [-Wunused-parameter]
   26 | int hubDistance(int n, int sub){
      |                        ~~~~^~~