# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
499919 |
2021-12-30T03:40:39 Z |
gozonite |
Pairs (IOI07_pairs) |
C++14 |
|
88 ms |
5080 KB |
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <deque>
#include <queue>
#include <tuple>
#include <cmath>
#include <cctype>
#include <stack>
#include <cassert>
using namespace std;
using ll = long long;
struct vert {
int x, y, t;
};
bool cmp(const vert& a, const vert& b) {
if (a.x != b.x) return a.x < b.x;
return a.t < b.t;
}
int B, N, D, M;
int inp[3][100001];
vert verts[200001];
int bit1[150002]={};
void addv(int k, int v) {
for(; k <= 150000; k += k&-k) bit1[k] += v;
}
int sumr(int k) {
int s = 0;
for (; k >= 1; k -= k&-k) s += bit1[k];
return s;
}
int main() {
cin >> B >> N >> D >> M;
if (B==1) {
for (int i = 1; i <= N; i++) cin >> inp[0][i];
sort(inp[0]+1, inp[0]+1+N);
int idx = 1;
ll cnt = 0;
for (int i = 1; i <= N; i++) {
while (idx < N && inp[0][i]+D >= inp[0][idx+1]) idx++;
cnt += (idx-i);
}
cout << cnt << endl;
} else if (B==2) {
for (int i = 1; i <= N; i++) cin >> inp[0][i] >> inp[1][i];
for (int i = 1; i <= N; i++) {
verts[2*i-1] = {inp[0][i]-inp[1][i], inp[0][i]+inp[1][i], 0};
verts[2*i] = {inp[0][i]-inp[1][i]+D, inp[0][i]+inp[1][i], 1};
}
sort(verts+1, verts+1+2*N, cmp);
ll ans = 0;
for (int i = 1; i <= 2*N; i++) {
int y = verts[i].y;
if (verts[i].t == 0) {
int fy = max(2, y-D), sy = min(2*M, y+D);
ans += sumr(sy)-sumr(fy-1);
addv(y, 1);
} else {
addv(y, -1);
}
}
cout << ans << endl;
} else if (B==3) {
for (int i = 1; i <= N; i++) cin >> inp[0][i] >> inp[1][i] >> inp[2][i];
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
0 ms |
300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1068 KB |
Output is correct |
2 |
Correct |
24 ms |
1020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
1480 KB |
Output is correct |
2 |
Correct |
40 ms |
1472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
1428 KB |
Output is correct |
2 |
Correct |
40 ms |
1556 KB |
Output is correct |
3 |
Correct |
40 ms |
1560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
896 KB |
Output is correct |
2 |
Correct |
2 ms |
844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
3924 KB |
Output is correct |
2 |
Correct |
52 ms |
4020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
4180 KB |
Output is correct |
2 |
Correct |
62 ms |
4188 KB |
Output is correct |
3 |
Correct |
62 ms |
4128 KB |
Output is correct |
4 |
Correct |
64 ms |
4144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
5060 KB |
Output is correct |
2 |
Correct |
88 ms |
5060 KB |
Output is correct |
3 |
Correct |
74 ms |
5080 KB |
Output is correct |
4 |
Correct |
73 ms |
5024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
2112 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
43 ms |
2252 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
49 ms |
2244 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |