제출 #313134

#제출 시각아이디문제언어결과실행 시간메모리
313134kylych03전선 연결 (IOI17_wiring)C++14
컴파일 에러
0 ms0 KiB
#include "wiring.h" #include <bits/stdc++.h> #include "grader.cpp" #define ll long long using namespace std; long long dp[200002]; long long inf = 1e15; long long MAXN =200005; long long balance[200005]; long long pref[200005]; vector <int> r,b; int getMin(pair<ll, bool> curr) { if(curr.second) { auto it = lower_bound(r.begin(), r.end(), curr.first); long long mn = inf; if(it != r.end()) mn = min(mn, *it - curr.first); if(it != r.begin()) {it --; mn = min(mn, curr.first - *it);} return mn; } else { auto it = lower_bound(b.begin(), b.end(), curr.first); long long mn = inf; if(it != b.end()) mn = min(mn, *it - curr.first); if(it != b.begin()) { it --; mn = min(mn, curr.first - *it); } return mn; } } long long min_total_length(std::vector<int> r1, std::vector<int> b1) { vector < pair <ll, bool> > pr; int n = r1.size(); int m = b1.size(); pr.resize(n+m); r.resize(n); r=r1; b.resize(m); b=b1; for(int i = 0 ; i < n; i++){ pr[i].first = r1[i]; pr[i].second = 0; } for(int i = 0 ; i < m; i++){ pr[i+n].first = b1[i]; pr[i+n].second = 1; } pr.push_back(make_pair(-inf, 0)); sort(pr.begin(), pr.end()); for(int i = 0 ; i < MAXN; i++) balance[i]=-1; long long curr = MAXN / 2; balance[curr] = 0; dp[0]=0; for(int i = 1 ; i <= n + m ; i++){ if(pr[i].second) { pref[i] = pref[i -1] - pr[i].first; curr --; } else { pref[i] = pref[i -1] + pr[i].first; curr ++; } dp[i] = dp[i-1] + getMin(pr[i]); if(balance[curr]!=-1){ dp[i] = min(dp[i], dp[balance[curr]] + abs(pref[i] - pref[balance[curr]])); } balance[curr] = i; } return dp[n+m]; }

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

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:53:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   53 |    for(int i = 0 ; i < MAXN; i++)
      |    ^~~
wiring.cpp:55:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   55 |     long long curr = MAXN / 2;
      |     ^~~~
/tmp/ccaKNsoN.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cciCswyX.o:wiring.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status