QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#149630 | #6136. Airdrop | pooty# | AC ✓ | 661ms | 42140kb | C++20 | 2.8kb | 2023-08-25 00:02:48 | 2023-08-25 00:02:49 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPL(i,j, n) for (int i = (j); i < (n); i++)
#define int long long
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int MAXX = 1e6;
int curman[MAXX*2];
vi toclear;
void solve() {
int n,y0;cin>>n>>y0;
vii arr(n);
map<int, vi> events;
// parity here...
set<int> tocheck;
REP(i, n) {
int x,y;cin>>x>>y;
tocheck.insert(x);
tocheck.insert(x+1);
y -= y0;
arr[i] = {x,y};
events[x].push_back(y);
}
tocheck.insert(0);
vi checkarr;
for (auto x: tocheck) {
checkarr.push_back(x);
}
int gg = checkarr.size();
vi sizes(gg);
vector<vii> realevents(gg);
REP(i, gg) {
int x = checkarr[i];
vi &vec = events[x];
map<int,int> ctmp;
sizes[i] = vec.size();
for (auto y: vec) {
ctmp[abs(y)]++;
}
for (auto [y,ct]: ctmp) {
realevents[i].push_back({y, ct});
}
}
vi arrL(gg,0);
vi arrR(gg,0);
int curval = 0;
REPL(i, 1, gg) {
int x = checkarr[i -1];
for (auto [y, ct]: realevents[i-1]) {
int v = MAXX-x+y;
curval -= curman[v];
if (ct == 2) {
curman[v] = 0;
} else {
curman[v] = 1 - curman[v];
}
curval += curman[v];
toclear.push_back(v);
}
arrL[i] = curval;
}
for (auto x: toclear) {
curman[x] = 0;
}
toclear.clear();
curval = 0;
for (int idx = gg-2; idx >=0; idx--) {
int x = checkarr[idx+1];
for (auto [y, ct]: realevents[idx + 1]) {
int v = x+y;
curval -= curman[v];
if (ct == 2) {
curman[v] = 0;
} else {
curman[v] = 1 - curman[v];
}
curval += curman[v];
toclear.push_back(v);
}
arrR[idx] = curval;
}
for (auto x: toclear) {
curman[x] = 0;
}
toclear.clear();
// for (auto x: checkarr) {
// cout<<x<<" ";
// }cout<<"\n";
// for (auto x: arrR) {
// cout<<x<<" ";
// }cout<<"\n";
int mn = n;
int mx = 0;
REP(i, gg) {
int c = arrL[i] + arrR[i] + sizes[i];
mn = min(mn, c);
mx = max(mx, c);
}
cout<<mn<<" "<<mx<<"\n";
}
signed main() {
memset(curman, 0, sizeof(curman));
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t; cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 19360kb
input:
3 3 2 1 2 2 1 3 5 3 3 2 1 2 5 4 3 2 3 1 3 4 3
output:
1 3 0 3 2 2
result:
ok 6 numbers
Test #2:
score: 0
Accepted
time: 661ms
memory: 42140kb
input:
3508 6 1 7 1 1 1 9 1 10 1 3 1 4 1 3 8 8 9 8 7 1 8 9 5 10 1 10 8 10 2 5 1 9 9 5 9 10 9 6 4 4 7 6 7 10 5 3 8 9 5 9 9 7 5 4 7 10 5 6 9 9 5 6 6 9 3 3 2 5 1 3 8 6 4 5 9 10 2 2 9 10 10 10 8 4 1 7 1 6 1 3 1 5 1 2 4 9 3 3 3 4 5 3 8 9 6 9 9 6 3 9 5 9 3 2 9 9 1 9 2 4 1 5 4 5 6 6 5 9 8 4 1 2 1 5 1 7 1 3 1 9 10...
output:
6 6 1 3 1 5 2 6 2 6 0 2 4 4 2 2 4 4 4 7 4 4 9 9 4 6 0 3 2 6 2 2 2 6 10 10 9 9 1 3 2 4 0 2 2 4 4 7 6 6 9 9 2 2 2 2 3 5 1 4 2 2 1 1 3 5 4 7 3 6 1 1 5 7 5 5 1 3 2 2 1 7 1 1 4 6 2 4 2 6 2 4 1 7 2 4 9 9 0 3 1 1 3 8 2 2 2 2 9 9 3 7 4 4 4 6 2 5 0 2 2 5 3 3 0 4 4 4 2 4 2 2 4 6 6 6 6 6 0 2 2 6 2 4 2 6 2 5 1 ...
result:
ok 7016 numbers