# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
49023 | 2018-05-21T10:34:02 Z | BThero | 새 집 (APIO18_new_home) | C++17 | 5000 ms | 16536 KB |
// Why am I so stupid? :c #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second typedef long long ll; using namespace std; const int INF = 1e9; struct shop { int x, tp, l, r; shop() { x = tp = l = r = 0; } } arr[300005]; struct que { int x, t; que() { x = t = 0; } } req[300005]; int ans[300005]; int rl[900005]; int mn[300005]; int n, m, k, q; void compressTime() { vector <int> vv; for (int i = 1; i <= n; ++i) { vv.pb(arr[i].l); vv.pb(arr[i].r); } for (int i = 1; i <= q; ++i) { vv.pb(req[i].t); } sort(all(vv)); vv.resize(unique(all(vv)) - vv.begin()); m = vv.size(); for (int i = 1; i <= n; ++i) { arr[i].l = upper_bound(all(vv), arr[i].l) - vv.begin(); arr[i].r = upper_bound(all(vv), arr[i].r) - vv.begin(); } for (int i = 1; i <= q; ++i) { req[i].t = upper_bound(all(vv), req[i].t) - vv.begin(); } } void compressX() { vector <int> vv; for (int i = 1; i <= n; ++i) { vv.pb(arr[i].x); } for (int i = 1; i <= q; ++i) { vv.pb(req[i].x); } sort(all(vv)); vv.resize(unique(all(vv)) - vv.begin()); for (int i = 1, ps; i <= n; ++i) { ps = upper_bound(all(vv), arr[i].x) - vv.begin(); rl[ps] = arr[i].x; arr[i].x = ps; } for (int i = 1, ps; i <= q; ++i) { ps = upper_bound(all(vv), req[i].x) - vv.begin(); rl[ps] = req[i].x; req[i].x = ps; } } void solve() { scanf("%d %d %d", &n, &k, &q); for (int i = 1; i <= n; ++i) { scanf("%d %d", &arr[i].x, &arr[i].tp); scanf("%d %d", &arr[i].l, &arr[i].r); } for (int i = 1; i <= q; ++i) { scanf("%d %d", &req[i].x, &req[i].t); } compressTime(); compressX(); for (int i = 1; i <= q; ++i) { for (int j = 1; j <= k; ++j) { mn[j] = INF; } for (int j = 1; j <= n; ++j) { if (arr[j].l <= req[i].t && req[i].t <= arr[j].r) { mn[arr[j].tp] = min(mn[arr[j].tp], abs(rl[req[i].x] - rl[arr[j].x])); } } for (int j = 1; j <= k; ++j) { ans[i] = max(ans[i], mn[j]); } } for (int i = 1; i <= q; ++i) { if (ans[i] == INF) { ans[i] = -1; } printf("%d\n", ans[i]); } } int main() { #ifdef BThero freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // BThero int tt = 1; while (tt--) { solve(); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 7380 KB | Output is correct |
2 | Correct | 9 ms | 7400 KB | Output is correct |
3 | Correct | 9 ms | 7476 KB | Output is correct |
4 | Correct | 9 ms | 7496 KB | Output is correct |
5 | Correct | 10 ms | 7624 KB | Output is correct |
6 | Correct | 8 ms | 7624 KB | Output is correct |
7 | Correct | 10 ms | 7624 KB | Output is correct |
8 | Correct | 12 ms | 7624 KB | Output is correct |
9 | Correct | 10 ms | 7624 KB | Output is correct |
10 | Correct | 12 ms | 7624 KB | Output is correct |
11 | Correct | 10 ms | 7624 KB | Output is correct |
12 | Correct | 12 ms | 7624 KB | Output is correct |
13 | Correct | 9 ms | 7624 KB | Output is correct |
14 | Correct | 9 ms | 7656 KB | Output is correct |
15 | Correct | 8 ms | 7660 KB | Output is correct |
16 | Correct | 8 ms | 7660 KB | Output is correct |
17 | Correct | 8 ms | 7660 KB | Output is correct |
18 | Correct | 10 ms | 7676 KB | Output is correct |
19 | Correct | 8 ms | 7676 KB | Output is correct |
20 | Correct | 8 ms | 7676 KB | Output is correct |
21 | Correct | 9 ms | 7676 KB | Output is correct |
22 | Correct | 8 ms | 7676 KB | Output is correct |
23 | Correct | 8 ms | 7676 KB | Output is correct |
24 | Correct | 8 ms | 7676 KB | Output is correct |
25 | Correct | 9 ms | 7676 KB | Output is correct |
26 | Correct | 9 ms | 7676 KB | Output is correct |
27 | Correct | 8 ms | 7676 KB | Output is correct |
28 | Correct | 8 ms | 7676 KB | Output is correct |
29 | Correct | 8 ms | 7676 KB | Output is correct |
30 | Correct | 8 ms | 7676 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 7380 KB | Output is correct |
2 | Correct | 9 ms | 7400 KB | Output is correct |
3 | Correct | 9 ms | 7476 KB | Output is correct |
4 | Correct | 9 ms | 7496 KB | Output is correct |
5 | Correct | 10 ms | 7624 KB | Output is correct |
6 | Correct | 8 ms | 7624 KB | Output is correct |
7 | Correct | 10 ms | 7624 KB | Output is correct |
8 | Correct | 12 ms | 7624 KB | Output is correct |
9 | Correct | 10 ms | 7624 KB | Output is correct |
10 | Correct | 12 ms | 7624 KB | Output is correct |
11 | Correct | 10 ms | 7624 KB | Output is correct |
12 | Correct | 12 ms | 7624 KB | Output is correct |
13 | Correct | 9 ms | 7624 KB | Output is correct |
14 | Correct | 9 ms | 7656 KB | Output is correct |
15 | Correct | 8 ms | 7660 KB | Output is correct |
16 | Correct | 8 ms | 7660 KB | Output is correct |
17 | Correct | 8 ms | 7660 KB | Output is correct |
18 | Correct | 10 ms | 7676 KB | Output is correct |
19 | Correct | 8 ms | 7676 KB | Output is correct |
20 | Correct | 8 ms | 7676 KB | Output is correct |
21 | Correct | 9 ms | 7676 KB | Output is correct |
22 | Correct | 8 ms | 7676 KB | Output is correct |
23 | Correct | 8 ms | 7676 KB | Output is correct |
24 | Correct | 8 ms | 7676 KB | Output is correct |
25 | Correct | 9 ms | 7676 KB | Output is correct |
26 | Correct | 9 ms | 7676 KB | Output is correct |
27 | Correct | 8 ms | 7676 KB | Output is correct |
28 | Correct | 8 ms | 7676 KB | Output is correct |
29 | Correct | 8 ms | 7676 KB | Output is correct |
30 | Correct | 8 ms | 7676 KB | Output is correct |
31 | Execution timed out | 5093 ms | 9296 KB | Time limit exceeded |
32 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5019 ms | 16536 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5091 ms | 16536 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 7380 KB | Output is correct |
2 | Correct | 9 ms | 7400 KB | Output is correct |
3 | Correct | 9 ms | 7476 KB | Output is correct |
4 | Correct | 9 ms | 7496 KB | Output is correct |
5 | Correct | 10 ms | 7624 KB | Output is correct |
6 | Correct | 8 ms | 7624 KB | Output is correct |
7 | Correct | 10 ms | 7624 KB | Output is correct |
8 | Correct | 12 ms | 7624 KB | Output is correct |
9 | Correct | 10 ms | 7624 KB | Output is correct |
10 | Correct | 12 ms | 7624 KB | Output is correct |
11 | Correct | 10 ms | 7624 KB | Output is correct |
12 | Correct | 12 ms | 7624 KB | Output is correct |
13 | Correct | 9 ms | 7624 KB | Output is correct |
14 | Correct | 9 ms | 7656 KB | Output is correct |
15 | Correct | 8 ms | 7660 KB | Output is correct |
16 | Correct | 8 ms | 7660 KB | Output is correct |
17 | Correct | 8 ms | 7660 KB | Output is correct |
18 | Correct | 10 ms | 7676 KB | Output is correct |
19 | Correct | 8 ms | 7676 KB | Output is correct |
20 | Correct | 8 ms | 7676 KB | Output is correct |
21 | Correct | 9 ms | 7676 KB | Output is correct |
22 | Correct | 8 ms | 7676 KB | Output is correct |
23 | Correct | 8 ms | 7676 KB | Output is correct |
24 | Correct | 8 ms | 7676 KB | Output is correct |
25 | Correct | 9 ms | 7676 KB | Output is correct |
26 | Correct | 9 ms | 7676 KB | Output is correct |
27 | Correct | 8 ms | 7676 KB | Output is correct |
28 | Correct | 8 ms | 7676 KB | Output is correct |
29 | Correct | 8 ms | 7676 KB | Output is correct |
30 | Correct | 8 ms | 7676 KB | Output is correct |
31 | Execution timed out | 5093 ms | 9296 KB | Time limit exceeded |
32 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 7380 KB | Output is correct |
2 | Correct | 9 ms | 7400 KB | Output is correct |
3 | Correct | 9 ms | 7476 KB | Output is correct |
4 | Correct | 9 ms | 7496 KB | Output is correct |
5 | Correct | 10 ms | 7624 KB | Output is correct |
6 | Correct | 8 ms | 7624 KB | Output is correct |
7 | Correct | 10 ms | 7624 KB | Output is correct |
8 | Correct | 12 ms | 7624 KB | Output is correct |
9 | Correct | 10 ms | 7624 KB | Output is correct |
10 | Correct | 12 ms | 7624 KB | Output is correct |
11 | Correct | 10 ms | 7624 KB | Output is correct |
12 | Correct | 12 ms | 7624 KB | Output is correct |
13 | Correct | 9 ms | 7624 KB | Output is correct |
14 | Correct | 9 ms | 7656 KB | Output is correct |
15 | Correct | 8 ms | 7660 KB | Output is correct |
16 | Correct | 8 ms | 7660 KB | Output is correct |
17 | Correct | 8 ms | 7660 KB | Output is correct |
18 | Correct | 10 ms | 7676 KB | Output is correct |
19 | Correct | 8 ms | 7676 KB | Output is correct |
20 | Correct | 8 ms | 7676 KB | Output is correct |
21 | Correct | 9 ms | 7676 KB | Output is correct |
22 | Correct | 8 ms | 7676 KB | Output is correct |
23 | Correct | 8 ms | 7676 KB | Output is correct |
24 | Correct | 8 ms | 7676 KB | Output is correct |
25 | Correct | 9 ms | 7676 KB | Output is correct |
26 | Correct | 9 ms | 7676 KB | Output is correct |
27 | Correct | 8 ms | 7676 KB | Output is correct |
28 | Correct | 8 ms | 7676 KB | Output is correct |
29 | Correct | 8 ms | 7676 KB | Output is correct |
30 | Correct | 8 ms | 7676 KB | Output is correct |
31 | Execution timed out | 5093 ms | 9296 KB | Time limit exceeded |
32 | Halted | 0 ms | 0 KB | - |