제출 #403120

#제출 시각아이디문제언어결과실행 시간메모리
403120fidgetspinnerkidTraffic (IOI10_traffic)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> // see /general/running-code-locally using namespace std; using ll = long long; using vi = vector<int>; #define pb push_back #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() using pi = pair<int,int>; #define f first #define s second #define mp make_pair void setIO(string name = "") { cin.tie(0)->sync_with_stdio(0); // see /general/fast-io if (sz(name)) { freopen((name+".in").c_str(), "r", stdin); // see /general/io freopen((name+".out").c_str(), "w", stdout); } } const int SZ = 1000; int n; vector<int> adjlist[SZ]; int p[SZ]; int pref[SZ+1]; void fill_pref() { for(int i=0; i<n; i++) { pref[i+1] = pref[i] + p[i]; } } int main() { setIO(); cin >> n; for(int i=0; i<n; i++) { int x; cin >> x; p[i] = x; } for(int i=0; i<n-1; i++) { int x, y; cin >> x >> y; adjlist[x-1].push_back(y-1); adjlist[y-1].push_back(x-1); } fill_pref(); int sol = 0; int min_cong = 2000000001; for(int i=0; i<n; i++) { int s = max(pref[i], pref[n-1]-pref[i+1]); if(min_cong>s) { min_cong = s; sol = i; } } }

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

traffic.cpp: In function 'int main()':
traffic.cpp:54:9: warning: variable 'sol' set but not used [-Wunused-but-set-variable]
   54 |     int sol = 0;
      |         ^~~
traffic.cpp: In function 'void setIO(std::string)':
traffic.cpp:19:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   freopen((name+".in").c_str(), "r", stdin); // see /general/io
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
traffic.cpp:20:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   freopen((name+".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccOnAMtd.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccgNjbjg.o:traffic.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccOnAMtd.o: in function `main':
grader.cpp:(.text.startup+0xe1): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status