# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
59280 | 2018-07-21T11:39:55 Z | Just_Solve_The_Problem | 새 집 (APIO18_new_home) | C++11 | 506 ms | 60800 KB |
#include <bits/stdc++.h> using namespace std; #define pii pair < int, int > #define fr first #define sc second #define mk make_pair #define pb push_back #define sz(s) (int)s.size() #define all(s) s.begin(), s.end() const int N = (int)3e5 + 7; const int inf = (int)1e9 + 7; int n, k, q; int x[N], t[N], a[N], b[N]; multiset < int > s[404]; int ans[N]; struct query { int type, x, t, y, ind; query() {} query(int _type, int _x, int _t, int _y) { type = _type; x = _x; t = _t; y = _y; } }; vector < query > vec; bool cmp(query &A, query &B) { if (A.y != B.y) return A.y < B.y; return A.type < B.type; } main() { scanf("%d %d %d", &n, &k, &q); for (int i = 1; i <= n; i++) { scanf("%d %d %d %d", &x[i], &t[i], &a[i], &b[i]); vec.pb(query(0, x[i], t[i], a[i])); vec.pb(query(2, x[i], t[i], b[i])); } for (int i = 1, l, y; i <= q; i++) { scanf("%d %d", &l, &y); vec.pb(query(1, l, 0, y)); vec.back().ind = i; } sort(all(vec), cmp); for (auto to : vec) { if (to.type == 0) { s[to.t].insert(to.x); } else if (to.type == 2) { s[to.t].erase(s[to.t].find(to.x)); } else { int res = -1; for (int i = 1; i <= k; i++) { if (s[i].empty()) { res = -1; break; } else { auto it = s[i].lower_bound(to.x); if (it != s[i].end()) res = max(res, abs(to.x - (*it))); if (it != s[i].begin()) { it--; res = max(res, abs(to.x - (*it))); } } } ans[to.ind] = res; } } for (int i = 1; i <= q; i++) { printf("%d\n", ans[i]); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 440 KB | Output is correct |
4 | Incorrect | 3 ms | 556 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 440 KB | Output is correct |
4 | Incorrect | 3 ms | 556 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 453 ms | 56748 KB | Execution killed with signal 7 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 506 ms | 60800 KB | Execution killed with signal 7 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 440 KB | Output is correct |
4 | Incorrect | 3 ms | 556 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 440 KB | Output is correct |
4 | Incorrect | 3 ms | 556 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |