제출 #922578

#제출 시각아이디문제언어결과실행 시간메모리
922578tvladm2009전선 연결 (IOI17_wiring)C++14
컴파일 에러
0 ms0 KiB
#include "wiring.h" #include <iostream> #include <complex> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <numeric> #include <cstring> #include <ctime> #include <cstdlib> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <list> #include <cmath> #include <bitset> #include <cassert> #include <queue> #include <stack> #include <deque> #include <random> using namespace std; template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;} template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;} #define files(FILENAME) read(FILENAME); write(FILENAME) #define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin) #define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout) #define all(c) (c).begin(), (c).end() #define sz(c) (int)(c).size() #define left left228 #define right right228 #define y1 y1228 #define mp make_pair #define pb push_back #define y2 y2228 #define rank rank228 using ll = long long; using ld = long double; const string FILENAME = "input"; ll min_total_lenght(vector<int> r, vector<int> b) { vector<int> pos[2]; pos[0] = r; pos[1] = b; vector<pair<int, int>> v; for (auto x: r) { v.pb(mp(x, 0)); } for (auto x: b) { v.pb(mp(x, 1)); } sort(all(v)); vector<ll> dp(sz(v), 1e18); map<int, int> mem; mem[0] = -1; int pr = 0; vector<ll> sum[2]; sum[0].resize(sz(v)); sum[1].resize(sz(v)); for (int i = 0; i < sz(v); i++) { if (i > 0) { sum[0][i] = sum[0][i - 1]; sum[1][i] = sum[1][i - 1]; } sum[v[i].second][i] += v[i].first; if (v[i].second == 1) { pr++; } else { pr--; } int op = v[i].second ^ 1; int ind = lower_bound(all(v[op]), v[i].first) - v[op]; ll close = 1e18; for (int d : {ind, ind - 1}) { if (0 <= d && d < sz(pos[d])) { chkmin(close, (ll)abs(pos[op][d] - v[i].x)); } } dp[i] = (i == 0 ? 0 : dp[i - 1]) + close; if (mem.count(pr)) { int l = mem[pr] + 1; ll offset = sum[v[i].second][i] - ((l - 1 >= 0) ? sum[v[i].second][l - 1] : 0); offset -= sum[1 - v[i].second][i] - ((l - 1 >= 0) ? sum[1 - v[i].second][l - 1] : 0); chkmin(dp[i], offset + ((l - i >= 0) ? dp[l - 1] : 0)); } mem[pr] = i; } return dp.back(); }

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

wiring.cpp: In function 'll min_total_lenght(std::vector<int>, std::vector<int>)':
wiring.cpp:31:20: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'begin'
   31 | #define all(c) (c).begin(), (c).end()
      |                    ^~~~~
wiring.cpp:75:25: note: in expansion of macro 'all'
   75 |   int ind = lower_bound(all(v[op]), v[i].first) - v[op];
      |                         ^~~
wiring.cpp:31:33: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'end'
   31 | #define all(c) (c).begin(), (c).end()
      |                                 ^~~
wiring.cpp:75:25: note: in expansion of macro 'all'
   75 |   int ind = lower_bound(all(v[op]), v[i].first) - v[op];
      |                         ^~~
wiring.cpp:79:45: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'x'
   79 |     chkmin(close, (ll)abs(pos[op][d] - v[i].x));
      |                                             ^