# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
262781 |
2020-08-13T08:52:43 Z |
임성재(#5086) |
Pairs (IOI07_pairs) |
C++17 |
|
84 ms |
20656 KB |
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define pre(a) cout << fixed; cout.precision(a);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define all(v) (v).begin() (v).end()
#define mp make_pair
#define mt make_tuple
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;
struct point {
ll x[3];
point() {
x[0] = x[1] = x[2] = 0;
}
bool operator<(point &p) {
return mt(x[0], x[1], x[2]) < mt(p.x[0], p.x[1], p.x[2]);
}
};
ll b, n, d, m;
point p[100010];
ll tree[800010];
vector<int> v[100010];
vector<pii> st[100010], ed[100010];
void update(int node, int s, int e, int i) {
if(s == e) {
tree[node]++;
return;
}
int m = (s+e)/2;
if(i <= m) update(node*2, s, m, i);
else update(node*2+1, m+1, e, i);
tree[node] = tree[node*2] + tree[node*2+1];
}
ll cal(int node, int s, int e, int l, int r) {
if(r < s || e < l) return 0;
if(l <= s && e <= r) return tree[node];
return cal(node*2, s, (s+e)/2, l, r) + cal(node*2+1, (s+e)/2+1, e, l, r);
}
int main() {
fast;
cin >> b >> n >> d >> m;
for(int i=1; i<=n; i++) {
for(int j=0; j<b; j++) {
cin >> p[i].x[j];
}
}
for(int i=1; i<=n; i++) {
int x = p[i].x[0];
int y = p[i].x[1];
v[x+y].eb(x - y);
st[max(2LL, x + y - d)].eb(max(1-m, x-y-d), min(m-1, x-y+d));
ed[min(2*m, x + y + d)].eb(max(1-m, x-y-d), min(m-1, x-y+d));
}
ll ans = 0;
for(int i=2; i<=2*m; i++) {
for(auto j : st[i]) {
ans -= cal(1, 1, 2*m-1, m+j.fi, m+j.se);
}
for(auto j : v[i]) {
update(1, 1, 2*m-1, m+j);
}
for(auto j : ed[i]) {
ans += cal(1, 1, 2*m-1, m+j.fi, m+j.se);
}
}
cout << (ans - n)/2;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
9728 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
19 ms |
19456 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
44 ms |
12520 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
33 ms |
19584 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
33 ms |
19516 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
23 ms |
20656 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
58 ms |
12544 KB |
Output is correct |
2 |
Correct |
41 ms |
12004 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
84 ms |
12928 KB |
Output is correct |
2 |
Correct |
76 ms |
12656 KB |
Output is correct |
3 |
Correct |
78 ms |
12884 KB |
Output is correct |
4 |
Correct |
74 ms |
12660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
46 ms |
19904 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
9760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
42 ms |
12408 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
58 ms |
12536 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
59 ms |
12664 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |