显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,k,max_e[300005],max_o[300005],min_e[300005],min_o[300005],T,a[300005],number[300005];
bool flag[300005];
signed main(){
freopen("Moo.in","r",stdin);
freopen("Moo.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>T;
while(T--){
n=0;
cin>>n>>m>>k;
for(int i=0;i<=300000;i++){
max_e[i]=max_o[i]=0;
min_e[i]=min_o[i]=2147483647;
flag[i]=0;
}
bool flag_for_for=false;
int now=n;
for(int i=1;i<=m;i++){
for(int j=1;j<=k;j++){
cin>>a[j];
if(a[j]%2==0){
max_e[i]=max(max_e[i],a[j]);
min_e[i]=min(min_e[i],a[j]);
}
else{
max_o[i]=max(max_o[i],a[j]);
min_o[i]=min(min_o[i],a[j]);
}
}
if(min_e[i]==2147483647){
flag[i]=true;
now+=min_o[i];
}
else if(min_o[i]==2147483647){
flag[i]=false;
now+=min_e[i];
}
else if(max_o[i]>max_e[i]){
flag[i]=true;
now-=max_e[i];
}
else{
flag[i]=false;
now-=max_o[i];
}
if(now<=0&&!flag_for_for){
cout<<"-1\n";
flag_for_for=true;
}
number[i]=now;
}
if(flag_for_for){
continue;
}
m--;
for(int i=m;i>=1;i--){
number[i]=min(number[i],number[i+1]);
}
m++;
int now_for_record=0;
for(int i=1;i<=m;i++){
if(flag[i]){
if(min_e[i]==2147483647){
if(min_o[i]+max_o[i]+now_for_record>=number[i]){
cout<<"Odd"<<" ";
}
else{
now_for_record+=min_o[i]+max_o[i];
cout<<"Even"<<" ";
}
}
else{
if(max_o[i]-max_e[i]+now_for_record>=number[i]){
cout<<"Odd"<<" ";
}
else{
now_for_record+=max_o[i]-max_e[i];
cout<<"Even"<<" ";
}
}
}
else{
cout<<"Even"<<" ";
}
}
cout<<'\n';
}
return 0;
}