QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#723436 | #9600. Eat, Sleep, Repeat | xinlengweishang | WA | 0ms | 3916kb | C++20 | 2.3kb | 2024-11-07 22:16:04 | 2024-11-07 22:16:05 |
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++){
printf(" %d %d\n",i,sst[i]);
ll sum=0;
ll nnum=0;
while(j<=n&&a[j]<sst[i+1]){
sum+=a[j]-(sst[i]+1);
j++;
nnum++;
}
ll ssum=0;
for(int m=sst[i]+1;m<sst[i+1];m++){
if(q<k&&st[q].first==m){
printf(" m=%d ssum=%lld nnum=%lld\n",m,ssum,nnum);
if(nnum-ssum<st[q].second) break;
sum-=nnum-ssum-st[q].second;
ssum+=st[q].second;
q++;
}
else break;
}
while(q<k&&st[q].first<=sst[i+1]) q++;
printf("q=%d sum=%lld\n",q,sum);
if(sum&1) ans=1-ans;
}
ll sum=0;
ll nnum=0;
while(j<=n){
sum+=a[j]-(sst[len-1]+1);
j++;
nnum++;
}
ll ssum=0;
for(int m=sst[len-1]+1;;m++){
if(q<k&&st[q].first==m){
printf(" m=%d ssum=%lld nnum=%lld\n",m,ssum,nnum);
if(nnum-ssum<st[q].second) break;
sum-=nnum-ssum-st[q].second;
ssum+=st[q].second;
q++;
}
else break;
}
printf("q=%d sum=%lld\n",q,sum);
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
*/
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3916kb
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 0 -1 q=3 sum=21 m=10 ssum=0 nnum=2 q=4 sum=8 Pico
result:
wrong answer 5th lines differ - expected: 'Pico', found: ' 0 -1'