# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
899743 |
2024-01-06T23:40:58 Z |
trMatherz |
Pairs (IOI07_pairs) |
C++17 |
|
4000 ms |
4436 KB |
#include <iostream> //cin, cout
/*
#include <fstream>
std::ifstream cin ("ex.in");
std::ofstream cout ("ex.out");
*/
// includes
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <unordered_set>
#include <stack>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>
#include <chrono>
//usings
using namespace std;
using namespace __gnu_pbds;
// misc
#define ll long long
#define pb push_back
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
template<typename T, typename U> bool emin(T &a, const U &b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool emax(T &a, const U &b){ return b > a ? a = b, true : false; }
typedef uint64_t hash_t;
// vectors
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vpii vector<pair<int, int>>
#define vvpii vector<vector<pair<int, int>>>
#define vppipi vector<pair<int, pair<int, int>>>
#define vl vector<ll>
#define vvl vector<vl>
#define vvvl vector<vvl>
#define vpll vector<pair<ll, ll>>
#define vb vector<bool>
#define vvb vector<vb>
#define vs vector<string>
#define sz(x) (int)x.size()
#define rz(x,y) x.resize(y)
#define all(x) x.begin(), x.end()
// pairs
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define f first
#define s second
// sets
#define si set<int>
#define sl set<ll>
#define ss set<string>
#define in insert
template <class T> using iset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// maps
#define mii map<int, int>
#define mll map<ll, ll>
// loops
#define FR(x, z, y) for (int x = z; x < y; x++)
#define FRe(x, z, y) FR(x, z, y + 1)
#define F(x, y) FR(x, 0, y)
#define Fe(x, y) F(x, y + 1)
#define A(x, y) for(auto &x : y)
vi bit;
void add(int x, int v){
for(x++; x <= 160'000; x += x & -x) bit[x] += v;
}
int get(int x){
int ret = 0;
for(x++; x; x -= x & -x) ret += bit[x];
return ret;
}
int main(){
int b, n, d, m; cin >> b >> n >> d >> m;
if(b == 1){
queue<int> cur;
ll an = 0;
vi a(n);
A(u, a) cin >> u;
sort(all(a));
F(i, n){
cur.push(a[i]);
while(!cur.empty() && a[i] - cur.front() > d) cur.pop();
an += sz(cur) - 1;
}
cout << an;
} else if(b == 2){
vpii a(n);
A(u, a) {
int x, y; cin >> x >> y;
u.f = x - y; u.s = x + y;
}
ll an = 0;
bit = vi(160'001, 0);
sort(all(a));
queue<pii> cur;
F(i, n){
cur.push(a[i]);
while(!cur.empty() && a[i].f - cur.front().f > d) {
add(cur.front().s - d, -1);
add(cur.front().s + d + 1, 1);
cur.pop();
}
an += get(a[i].s);
add(a[i].s - d, 1);
add(a[i].s + d + 1, -1);
}
cout << an;
} else {
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
840 KB |
Output is correct |
2 |
Correct |
20 ms |
1096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
600 KB |
Output is correct |
2 |
Correct |
31 ms |
1356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
604 KB |
Output is correct |
2 |
Correct |
32 ms |
852 KB |
Output is correct |
3 |
Correct |
32 ms |
824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
860 KB |
Output is correct |
2 |
Runtime error |
2 ms |
1628 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4066 ms |
2388 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4043 ms |
2600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
51 ms |
4436 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |