比赛 |
2024.12.21 |
评测结果 |
AAAAAAAAAAAA |
题目名称 |
Moorbles |
最终得分 |
100 |
用户昵称 |
flyfree |
运行时间 |
0.538 s |
代码语言 |
C++ |
内存使用 |
9.26 MiB |
提交时间 |
2024-12-21 15:07:23 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAXN 300010
//By flyfreemrn
inline ll read(){
ll x=0,f=1;
char c=getchar();
while(c<'0'||c>'9'){
if(c=='-')f=-1;
c=getchar();
}
while(c>='0'&&c<='9'){
x=x*10+c-'0';
c=getchar();
}
return x*f;
}
ll Emax[MAXN],Emin[MAXN],Omax[MAXN],Omin[MAXN],ans[MAXN],minz[MAXN];//E:0 O:1
ll T,n,m,k,p,s,sum;
int main(){
freopen("Moo.in","r",stdin);
freopen("Moo.out","w",stdout);
T=read();
while(T--){
sum=0;
p=0;
s=n=read(),m=read(),k=read();
for(int i=1;i<=m;i++){
Emax[i]=Omax[i]=0;
Emin[i]=Omin[i]=1e9;
for(int j=1;j<=k;j++){
ll a=read();
if(a&1)Omax[i]=max(Omax[i],a),Omin[i]=min(Omin[i],a);
else Emax[i]=max(Emax[i],a),Emin[i]=min(Emin[i],a);
}
if(Emin[i]==1e9){
ans[i]=1;
n+=Omin[i];
// f[i]+=Omin[i];
}else if(Omin[i]==1e9){
ans[i]=0;
n+=Emin[i];
// f[i]=Emin[i];
}else if(Omax[i]>Emax[i]){
ans[i]=1;
n-=Emax[i];
// f[i]=-Emax[i];
}else{
ans[i]=0;
n-=Omax[i];
// f[i]=-Omax[i];
}
if(n<=0)p=1;//E偶 O奇
minz[i]=n;
// cout<<Emin[i]<<" "<<Emax[i]<<" "<<Omin[i]<<" "<<Omax[i]<<" "<<n<<endl;
}
if(p){
cout<<"-1\n";
continue;
}
for(int i=m-1;i;i--)minz[i]=min(minz[i+1],minz[i]);
for(int i=1;i<=m;i++){
// s=min(s)
ll now=min(s,minz[i]);
if(ans[i]==0)cout<<"Even ";
else{
ll f=0;
if(Emin[i]==1e9)f=Omin[i]+Omax[i];
else f=Omax[i]-Emax[i];
// cout<<f<<" "<<n;
if(sum+f<minz[i]){
sum+=f;
cout<<"Even ";
}else cout<<"Odd ";
}
}
cout<<endl;
}
return 0;
}