이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
struct Q {
int t, x, y;
};
const int N = 1e6 + 5;
vector<Q> qrs;
vector<pair<int, int>> pts;
vector<int> vy, app_time;
int t[N * 4];
void upd(int x, int y, int v, int L, int R) {
t[v] = max(t[v], y);
// cout << L << " " << R << "\n";
if (L != R) {
int m = (L + R) >> 1;
if (x <= m)
upd(x, y, v * 2, L, m);
else
upd(x, y, v * 2 + 1, m + 1, R);
}
}
int que(int x, int y, int v, int L, int R) {
// cout << x << " " << y << " " << L << " " << R << " " << t[v] << "\n";
if (R < x || t[v] < y)
return -1;
if (t[v] < y)
return -1;
if (L == R)
return L;
int m = (L + R) >> 1,
res = que(x, y, v * 2, L, m);
if (res == -1)
res = que(x, y, v * 2 + 1, m + 1, R);
return res;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m, q;
cin >> n >> m >> q;
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
pts.push_back({x, y});
app_time.push_back(0);
}
for (int i = 0, j = 0; i < q; i++) {
int type, x;
cin >> type >> x;
if (type == 1) {
qrs.push_back({type, x - 1});
}
else if (type == 2) {
vy.push_back(x);
qrs.push_back({type, x, j});
j++;
}
else {
int y;
cin >> y;
pts.push_back({x, y});
app_time.push_back(j);
}
}
vy.push_back(-1);
sort(all(vy));
vy.erase(unique(all(vy)), vy.end());
memset(t, -1, sizeof(t));
int j = 0;
for (const Q &q : qrs) {
if (q.t == 1) {
int res = que(lower_bound(all(vy), pts[q.x].second) - vy.begin(), app_time[q.x], 1, 0, vy.size() - 1);
if (res == -1)
cout << pts[q.x].first << " " << pts[q.x].second << "\n";
else
cout << max(pts[q.x].first, n - vy[res]) << " " << pts[q.x].second << "\n";
}
else if (q.t == 2) {
upd(lower_bound(all(vy), q.x) - vy.begin(), q.y, 1, 0, vy.size() - 1);
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
sweeping.cpp: In function 'int main()':
sweeping.cpp:86:9: warning: unused variable 'j' [-Wunused-variable]
int j = 0;
^
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |