# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
262784 |
2020-08-13T08:54:10 Z |
임성재(#5086) |
Pairs (IOI07_pairs) |
C++17 |
|
266 ms |
91028 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[1500010];
vector<pii> st[150010], ed[150010];
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
44928 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
88 ms |
90872 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
66 ms |
47736 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
98 ms |
90836 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 |
105 ms |
91028 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 |
34 ms |
47744 KB |
Output is correct |
2 |
Correct |
35 ms |
47752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
47780 KB |
Output is correct |
2 |
Correct |
70 ms |
47336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
124 ms |
48140 KB |
Output is correct |
2 |
Correct |
102 ms |
47856 KB |
Output is correct |
3 |
Correct |
101 ms |
48212 KB |
Output is correct |
4 |
Correct |
106 ms |
47812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
266 ms |
55384 KB |
Output is correct |
2 |
Correct |
203 ms |
54800 KB |
Output is correct |
3 |
Correct |
136 ms |
51188 KB |
Output is correct |
4 |
Correct |
139 ms |
51192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
45048 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
69 ms |
47704 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
101 ms |
47744 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
84 ms |
48008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |