# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
263206 |
2020-08-13T14:03:48 Z |
sjimed |
Pairs (IOI07_pairs) |
C++14 |
|
150 ms |
91952 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[150010];
vector<int> v[1500010];
vector<pii> st[150010], ed[150010];
void update(int i) {
while(i <= 150010) {
tree[i]++;
i += i & -i;
}
}
ll cal(int i) {
ll ret = 0;
while(i) {
ret += tree[i];
i -= i & -i;
}
return ret;
}
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(m+j.se) - cal(m+j.fi-1);
}
for(auto j : v[i]) {
update(m+j);
}
for(auto j : ed[i]) {
ans += cal(m+j.se) - cal(m+j.fi-1);
}
}
cout << (ans - n)/2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
44920 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
85 ms |
90916 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
48120 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
97 ms |
91952 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
95 ms |
91712 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
46336 KB |
Output is correct |
2 |
Correct |
32 ms |
46208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
48380 KB |
Output is correct |
2 |
Correct |
57 ms |
47756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
48888 KB |
Output is correct |
2 |
Correct |
65 ms |
48640 KB |
Output is correct |
3 |
Correct |
67 ms |
48760 KB |
Output is correct |
4 |
Correct |
63 ms |
48624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
141 ms |
53624 KB |
Output is correct |
2 |
Correct |
150 ms |
52976 KB |
Output is correct |
3 |
Correct |
74 ms |
50296 KB |
Output is correct |
4 |
Correct |
70 ms |
50296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
29 ms |
45056 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
61 ms |
48408 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
64 ms |
48632 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
64 ms |
48696 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |