제출 #105795

#제출 시각아이디문제언어결과실행 시간메모리
105795gs18103먼 별 (KOI16_dist)C++98
0 / 100
4 ms512 KiB
#include <bits/stdc++.h> using namespace std; long long arr[1010][4]; long long ans; int n, T; long long dp[10101010]; long long cal_dis(int t) { if(dp[t] != 0) return dp[t]; long long dis; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(i == j) continue; dis = max(dis, (arr[i][0]-arr[j][0]+t*(arr[i][2]-arr[j][2]))*(arr[i][0]-arr[j][0]+t*(arr[i][2]-arr[j][2]))+ (arr[i][1]-arr[j][1]+t*(arr[i][3]-arr[j][3]))*(arr[i][1]-arr[j][1]+t*(arr[i][3]-arr[j][3]))); } } return dp[t] = dis; } int search(int s, int e) { if(s == e) { return s; } if(s + 1 == e) { if(cal_dis(s) > cal_dis(e)) return e; else return s; } if(s + 2 == e) { long long d = min(cal_dis(s), min(cal_dis(s+1), cal_dis(e))); if(d == cal_dis(s)) return s; if(d == cal_dis(s+1)) return s+1; if(d == cal_dis(e)) return e; } int t1 = s + (e - s) / 3, t2 = s + ((e - s) * 2) / 3; long long dis1 = cal_dis(t1), dis2 = cal_dis(t2); if(dis1 < dis2) return search(s, t2-1); else return search(t1+1, e); } int main() { scanf("%d %d", &n, &T); for(int i = 0; i < n; i++) for(int j = 0; j < 4; j++) scanf("%lld", &arr[i][j]); int ans = search(0, T); printf("%d\n%lld", ans, cal_dis(ans)); }

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

dist.cpp: In function 'int main()':
dist.cpp:52:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &T);
  ~~~~~^~~~~~~~~~~~~~~~~
dist.cpp:55:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%lld", &arr[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~~~~~
dist.cpp: In function 'long long int cal_dis(int)':
dist.cpp:13:12: warning: 'dis' may be used uninitialized in this function [-Wmaybe-uninitialized]
  long long dis;
            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...