QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#692527 | #6136. Airdrop | A_Quark# | WA | 0ms | 5600kb | C++20 | 2.7kb | 2024-10-31 14:39:48 | 2024-10-31 14:39:54 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
//#define DEBUG
#ifdef DEBUG
const ll N = 1010;
#endif
#ifndef DEBUG
const ll N = 1000100;
#endif
bool cmp(pii x, pii y)
{
if(x.first != y.first) return x.first < y.first;
return abs(x.second) < abs(y.second);
}
const ll BIAS = 500000;
ll ans[N];
pii a[N];
bool field[N];
bool rep(pii x, pii y)
{
return x.first == y.first && abs(x.second) == abs(y.second);
}
int main()
{
#ifdef DEBUG
freopen("1.txt", "r", stdin);
#endif
#ifndef DEBUG
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
#endif
ll z;
cin >> z;
while(z--)
{
ll n, y0;
cin >> n >> y0;
ll maxx = -1;
for(ll i=0; i<n; i++)
{
ll x, y;
cin >> x >> y;
y -= y0;
a[i] = {x, y};
maxx = max(maxx, x);
}
sort(a, a+n, cmp);
vector<ll> dirty;
memset(ans+BIAS-maxx-5, 0, sizeof(ll) * ((maxx) * 2 + 10));
ll i = 0;
ll survive = 0;
for(ll pos = 0; pos <= maxx; pos++)
{
if(i == n) ;
else
{
while(a[i].first < pos) i++;
while(a[i].first == pos)
{
ans[pos+BIAS] ++;
ll conflict = a[i].first - abs(a[i].second);
bool &group = field[conflict + BIAS];
dirty.push_back(conflict + BIAS);
if(rep(a[i], a[i-1])) // conflict on column
{
if(group)survive--;
group = 0;
}
else // no conflict, xor
{
if(group) survive--;
else survive++;
group = !group;
}
i++;
}
}
ans[pos+1+BIAS] += survive;
}
for(ll i = maxx+2; i <= maxx * 3 / 2 + 5; i++)
ans[i+BIAS] += survive;
// Clear TODO
for(ll i: dirty)
field[i] = 0;
dirty.clear();
survive = 0; i = n-1;
for(ll pos = maxx; pos>=0; pos--)
{
if(i == -1) ;
else {
while(a[i].first > pos) i--;
while(a[i].first == pos)
{
ll conflict = a[i].first + abs(a[i].second);
bool &group = field[conflict + BIAS];
dirty.push_back(conflict + BIAS);
if(rep(a[i], a[i+1]) )
{
if(group) survive--;
group = 0;
}
else
{
if(group) survive--;
else survive++;
group = !group;
}
i--;
}
}
ans[pos-1+BIAS] += survive;
}
for(ll i = -2; i >= -(maxx / 2) - 5; i--)
ans[i+BIAS] += survive;
// Clear TODO
for(ll i: dirty)
field[i] = 0;
// out
ll maxans, minans;
maxans = 0x8080808080808080;
minans = 0x7f7f7f7f7f7f7f7f;
for(ll i=-(maxx / 2) - 5; i <= 3*maxx / 2 + 5; i++)
{
maxans = max(maxans, ans[i]);
minans = min(minans, ans[i]);
}
cout << minans << ' ' << maxans << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 5600kb
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:
0 0 0 0 0 0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'