이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/extc++.h"
using namespace std;
template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
cerr << t;
((cerr << " | " << u), ...);
cerr << endl;
}
#ifdef DEBUG
#define dbg(...) \
cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
dbgh(__VA_ARGS__)
#else
#define dbg(...)
#define cerr \
if (false) \
cerr
#endif
using ll = long long;
#define endl "\n"
#define long int64_t
#define sz(x) int(std::size(x))
inline void init_io() {
cin.tie(nullptr);
cin.exceptions(ios::failbit);
ios_base::sync_with_stdio(false);
}
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& arr) {
out << "[";
for (int i = 0; i < sz(arr); i++) {
if (i) {
out << ", ";
}
out << arr[i];
}
return out << "]";
}
template <typename T>
struct PSA {
int n;
vector<T> psum;
template <typename U>
PSA(const vector<U>& arr) : n(sz(arr)), psum(n + 1) {
for (int i = 0; i < n; i++) {
psum[i + 1] = psum[i] + arr[i];
}
}
T query(int l, int r) const {
return psum[r] - psum[l];
}
};
template <typename T>
bool on(T mask, int bit) {
return (mask >> bit) & 1;
}
template <typename T>
vector<T> iota(int n, T x) {
vector<T> arr(n);
iota(begin(arr), end(arr), x);
return arr;
}
template <typename T>
T reversed(T arr) {
reverse(begin(arr), end(arr));
return arr;
}
template <typename A, typename B>
ostream& operator<<(ostream& out, const pair<A, B>& p) {
return out << "(" << p.first << ", " << p.second << ")";
}
struct Solver {
int n;
vector<pair<int, int>> arr;
Solver() {}
Solver(const vector<pair<int, int>>& arr) : n(sz(arr)), arr(arr) {}
bool query(const vector<int>& qarr) {
dbg(arr, qarr);
auto query2 = [&](int ql, int qr) -> int {
int ans = 0;
for (auto& [l, r] : arr) {
ans += ql < l && l <= qr && qr <= r;
}
return ans;
};
map<int, int> cc_mp;
for (auto& a : qarr) {
cc_mp[a] += a;
}
vector<pair<int, int>> carr(begin(cc_mp), end(cc_mp));
carr.insert(begin(carr), pair {-1, 0});
int m = sz(carr);
vector dp(m, 0);
for (int i = m - 1; i >= 0; i--) {
for (int j = i + 1; j < m; j++) {
dp[i] = min(dp[i], query2(carr[i].first, carr[j].first) + dp[j] - carr[j].second);
}
}
return dp[0] >= 0;
}
} solver;
void init(int n, int arra[], int arrb[]) {
solver = Solver([&]() {
vector<pair<int, int>> cv;
for (int i = 0; i < n; i++) {
cv.emplace_back(arra[i], arrb[i]);
}
return cv;
}());
}
int can(int m, int arr[]) {
return solver.query(vector(arr, arr + m));
}
컴파일 시 표준 에러 (stderr) 메시지
teams.cpp: In constructor 'Solver::Solver(const std::vector<std::pair<int, int> >&)':
teams.cpp:92:42: warning: declaration of 'arr' shadows a member of 'Solver' [-Wshadow]
92 | Solver(const vector<pair<int, int>>& arr) : n(sz(arr)), arr(arr) {}
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
teams.cpp:89:28: note: shadowed declaration is here
89 | vector<pair<int, int>> arr;
| ^~~
teams.cpp: In constructor 'Solver::Solver(const std::vector<std::pair<int, int> >&)':
teams.cpp:92:42: warning: declaration of 'arr' shadows a member of 'Solver' [-Wshadow]
92 | Solver(const vector<pair<int, int>>& arr) : n(sz(arr)), arr(arr) {}
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
teams.cpp:89:28: note: shadowed declaration is here
89 | vector<pair<int, int>> arr;
| ^~~
teams.cpp: In constructor 'Solver::Solver(const std::vector<std::pair<int, int> >&)':
teams.cpp:92:42: warning: declaration of 'arr' shadows a member of 'Solver' [-Wshadow]
92 | Solver(const vector<pair<int, int>>& arr) : n(sz(arr)), arr(arr) {}
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
teams.cpp:89:28: note: shadowed declaration is here
89 | vector<pair<int, int>> arr;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |