# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
372970 | 2021-03-02T18:44:57 Z | luciocf | Examination (JOI19_examination) | C++14 | 3000 ms | 265060 KB |
#include <bits/stdc++.h> #define ff first #define ss second using namespace std; typedef pair<int, int> pii; const int maxn = 2e5+10; struct BIT2D { unordered_map<int, int> bit[maxn]; void upd(int x, int y, int v) { for (int i = x; i < maxn; i += (i&-i)) for (int j = y; j < maxn; j += (j&-j)) bit[i][j] += v; } int soma(int x, int y) { int ans = 0; for (int i = x; i > 0; i -= (i&-i)) for (int j = y; j > 0; j -= (j&-j)) ans += bit[i][j]; return ans; } } BIT; struct Query { int x, y, z, ind; } query[maxn]; pii a[maxn]; int ans[maxn]; int main(void) { int n, q; scanf("%d %d", &n, &q); map<int, int> mpx, mpy; for (int i = 1; i <= n; i++) { scanf("%d %d", &a[i].ff, &a[i].ss); mpx[a[i].ff] = 0; mpy[a[i].ss] = 0; } for (int i = 1; i <= q; i++) { scanf("%d %d %d", &query[i].x, &query[i].y, &query[i].z); query[i].ind = i; mpx[query[i].x] = 0; mpy[query[i].y] = 0; } int aux = 0; for (auto &x: mpx) x.second = ++aux; aux = 0; for (auto &x: mpy) x.second = ++aux; sort(a+1, a+n+1, [&] (pii a, pii b) {return a.ff+a.ss > b.ff+b.ss;}); sort(query+1, query+q+1, [&] (Query a, Query b) {return a.z > b.z;}); int ptr = 1; for (int i = 1; i <= q; i++) { while (ptr <= n && a[ptr].ff+a[ptr].ss >= query[i].z) { BIT.upd(maxn-mpx[a[ptr].ff], maxn-mpy[a[ptr].ss], 1); ptr++; } ans[query[i].ind] = BIT.soma(maxn-mpx[query[i].x], maxn-mpy[query[i].y]); } for (int i = 1; i <= q; i++) printf("%d\n", ans[i]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 11372 KB | Output is correct |
2 | Correct | 8 ms | 11372 KB | Output is correct |
3 | Correct | 9 ms | 11372 KB | Output is correct |
4 | Correct | 8 ms | 11372 KB | Output is correct |
5 | Correct | 8 ms | 11372 KB | Output is correct |
6 | Correct | 8 ms | 11372 KB | Output is correct |
7 | Correct | 61 ms | 19692 KB | Output is correct |
8 | Correct | 61 ms | 19692 KB | Output is correct |
9 | Correct | 67 ms | 19564 KB | Output is correct |
10 | Correct | 25 ms | 13804 KB | Output is correct |
11 | Correct | 25 ms | 13824 KB | Output is correct |
12 | Correct | 15 ms | 11372 KB | Output is correct |
13 | Correct | 64 ms | 19692 KB | Output is correct |
14 | Correct | 67 ms | 19692 KB | Output is correct |
15 | Correct | 78 ms | 19712 KB | Output is correct |
16 | Correct | 21 ms | 13164 KB | Output is correct |
17 | Correct | 21 ms | 13164 KB | Output is correct |
18 | Correct | 13 ms | 11372 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3082 ms | 265060 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3082 ms | 265060 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 11372 KB | Output is correct |
2 | Correct | 8 ms | 11372 KB | Output is correct |
3 | Correct | 9 ms | 11372 KB | Output is correct |
4 | Correct | 8 ms | 11372 KB | Output is correct |
5 | Correct | 8 ms | 11372 KB | Output is correct |
6 | Correct | 8 ms | 11372 KB | Output is correct |
7 | Correct | 61 ms | 19692 KB | Output is correct |
8 | Correct | 61 ms | 19692 KB | Output is correct |
9 | Correct | 67 ms | 19564 KB | Output is correct |
10 | Correct | 25 ms | 13804 KB | Output is correct |
11 | Correct | 25 ms | 13824 KB | Output is correct |
12 | Correct | 15 ms | 11372 KB | Output is correct |
13 | Correct | 64 ms | 19692 KB | Output is correct |
14 | Correct | 67 ms | 19692 KB | Output is correct |
15 | Correct | 78 ms | 19712 KB | Output is correct |
16 | Correct | 21 ms | 13164 KB | Output is correct |
17 | Correct | 21 ms | 13164 KB | Output is correct |
18 | Correct | 13 ms | 11372 KB | Output is correct |
19 | Execution timed out | 3082 ms | 265060 KB | Time limit exceeded |
20 | Halted | 0 ms | 0 KB | - |