제출 #313232

#제출 시각아이디문제언어결과실행 시간메모리
313232talant117408전선 연결 (IOI17_wiring)C++17
컴파일 에러
0 ms0 KiB
#include "wiring.h"
#include <bits/stdc++.h>
#include "wiring.h"

using namespace std;
 
typedef long long ll;
typedef pair <ll, ll> pii;
 
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) (int)(v).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll INF = 1e18;
const N = 2e5+7;

ll dp[N], pref[N];
int last[N];

ll min_total_length(vector<int> r, vector<int> b) {
    int nr = r.size(), nb = b.size(), n = nr + nb;
	vector <pii> v;
	for (int i = 0; i < nr; i++) {
        v.push_back({r[i], 0});
	}
	for (int i = 0; i < nb; i++) {
        v.push_back({b[i], 1});
	}
  	sort(all(v));
	dp[0] = INF;
  	pref[0] = v[0].first;
    last[0] = -1;
    for (int i = 1; i < n; i++) {
        dp[i] = INF;
        pref[i] = pref[i - 1] + v[i].first;
        last[i] = (v[i].second == v[i - 1].second) ? last[i - 1] : i - 1;
        if (last[i] == -1) continue;
        dp[i] = min(dp[i], dp[i - 1] + v[i].first - v[last[i]].first);
       
        if (last[last[i]] < last[i] - (i - last[i]) + 1) {
            dp[i] = min(dp[i], (pref[i] - pref[last[i]]) - (pref[last[i]] - pref[last[i] - (i - last[i])]) + dp[last[i] - (i - last[i])]);
        }
    }
    return dp[n - 1];
}

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

wiring.cpp:24:7: error: 'N' does not name a type
   24 | const N = 2e5+7;
      |       ^
wiring.cpp:26:7: error: 'N' was not declared in this scope
   26 | ll dp[N], pref[N];
      |       ^
wiring.cpp:26:16: error: 'N' was not declared in this scope
   26 | ll dp[N], pref[N];
      |                ^
wiring.cpp:27:10: error: 'N' was not declared in this scope
   27 | int last[N];
      |          ^
wiring.cpp: In function 'll min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:39:2: error: 'dp' was not declared in this scope; did you mean 'mp'?
   39 |  dp[0] = INF;
      |  ^~
      |  mp
wiring.cpp:40:4: error: 'pref' was not declared in this scope
   40 |    pref[0] = v[0].first;
      |    ^~~~
wiring.cpp:41:5: error: 'last' was not declared in this scope
   41 |     last[0] = -1;
      |     ^~~~