QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#723397 | #9600. Eat, Sleep, Repeat | xinlengweishang | WA | 0ms | 3824kb | C++20 | 2.0kb | 2024-11-07 22:05:23 | 2024-11-07 22:05:24 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool cmp(pair<ll,ll> a,pair<ll,ll> b){
return a.first<b.first;
}
vector<pair<ll,ll> > st;
vector<int> sst;
ll a[1000010];
void slove(){
st.clear();
sst.clear();
ll n,k;
scanf("%lld%lld",&n,&k);
ll ans=0;
for(ll i=1;i<=n;i++){
scanf("%lld",&a[i]);
}
sort(a+1,a+n+1);
for(ll i=0;i<k;i++){
ll a,b;
scanf("%lld%lld",&a,&b);
st.push_back({a,b});
}
sort(st.begin(),st.end(),cmp);
sst.push_back(-1);
for(int i=0;i<k;i++){
if(st[i].second==0){
sst.push_back(st[i].first);
}
}
if(sst.size()==1){
ll sum=0;
for(int i=1;i<=n;i++){
sum+=a[i];
}
ll ssum=0;
for(int i=0;i<k;i++){
if(st[i].first==i){
if(n-ssum<st[i].second) break;
sum-=n-ssum-st[i].second;
ssum+=st[i].second;
}
else break;
}
if(sum&1) ans=1-ans;
}
else{
int len=sst.size();
int j=1,q=0;
for(int i=0;i<len-1;i++){
ll sum=0;
ll nnum=0;
while(j<=n&&a[j]<sst[i+1]){
sum+=a[j];
j++;
nnum++;
}
ll ssum=0;
for(int m=sst[i]+1;m<sst[i+1];m++){
if(q<k&&st[q].first==m){
if(nnum-ssum<st[q].second) break;
sum-=nnum-ssum-st[q].second;
ssum+=st[q].second;
q++;
}
else break;
}
if(sum&1) ans=1-ans;
}
ll sum=0;
ll nnum=0;
while(j<=n){
sum+=a[j];
j++;
nnum++;
}
ll ssum=0;
for(int m=sst[len-1]+1;;m++){
if(q<k&&st[q].first==m){
if(nnum-ssum<st[q].second) break;
sum-=nnum-ssum-st[q].second;
ssum+=st[q].second;
q++;
}
else break;
}
if(sum&1) ans=1-ans;
}
if(ans&1) printf("Pico\n");
else printf("FuuFuu\n");
return ;
}
int main(){
ll T;
scanf("%lld",&T);
while(T--) slove();
return 0;
}
/*
5
2 0
1 2
2 1
1 2
0 1
3 2
3 3 4
0 2
1 1
3 2
2 3 3
1 2
0 1
5 4
6 7 8 12 17
1 1
2 1
9 0
10 1
*/
/*
1
5 4
6 7 8 12 17
1 1
2 1
9 0
10 1
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3824kb
input:
5 2 0 1 2 2 1 1 2 0 1 3 2 3 3 4 0 2 1 1 3 2 2 3 3 1 2 0 1 5 4 6 7 8 12 17 1 1 2 1 9 0 10 1
output:
Pico FuuFuu Pico FuuFuu FuuFuu
result:
wrong answer 5th lines differ - expected: 'Pico', found: 'FuuFuu'