# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1040885 |
2024-08-01T11:26:20 Z |
ArthuroWich |
Pairs (IOI07_pairs) |
C++17 |
|
4000 ms |
3420 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int b, n, d, m, ans = 0;
void solve1() {
vector<int> a(n);
for (int &x : a) {
cin >> x;
}
sort(a.begin(), a.end());
for (int i = 0; i < n; i++) {
int r = upper_bound(a.begin(), a.end(), a[i]+d) - a.begin();
ans += r-i-1;
}
}
void solve2() {
vector<pair<int, int>> a(n);
for (auto &[x, y] : a) {
cin >> x >> y;
}
for (int i = 0; i < n; i++) {
for (int j = i+1; j < n; j++) {
auto [x1, y1] = a[i];
auto [x2, y2] = a[j];
if (abs(x1-x2)+abs(y1-y2) <= d) {
ans++;
}
}
}
}
void solve3() {
vector<tuple<int, int, int>> a(n);
for (auto &[x, y, z] : a) {
cin >> x >> y >> z;
}
for (int i = 0; i < n; i++) {
for (int j = i+1; j < n; j++) {
auto [x1, y1, z1] = a[i];
auto [x2, y2, z2] = a[j];
if (abs(x1-x2)+abs(y1-y2)+abs(z1-z2) <= d) {
ans++;
}
}
}
}
void solve() {
cin >> b >> n >> d >> m;
if (b == 1) {
solve1();
} else if (b == 2) {
solve2();
} else {
solve3();
}
cout << ans << endl;
}
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
t = 1;
while(t--) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1488 KB |
Output is correct |
2 |
Correct |
9 ms |
1624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1880 KB |
Output is correct |
2 |
Correct |
12 ms |
1880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2136 KB |
Output is correct |
2 |
Correct |
13 ms |
1884 KB |
Output is correct |
3 |
Correct |
11 ms |
1884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4077 ms |
2396 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4037 ms |
2652 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4074 ms |
3048 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4054 ms |
3420 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4025 ms |
3416 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4053 ms |
3420 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |