QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#131484 | #2971. Wordle with Friends | SinhoMoeme | WA | 1ms | 1888kb | C++23 | 1.4kb | 2023-07-27 11:07:14 | 2023-07-27 11:07:18 |
Judging History
answer
#include<cstdio>
#include<cctype>
#include<algorithm>
#define NUM 26
#define SIZE 5
#define OFFSET 'A'
using std::max;
int N,W,ch,a[NUM];
bool v[NUM]={0},y[NUM][SIZE]={0};
char grn[SIZE]={0};
struct wrd{
char s[SIZE]={0};
inline void read(){
for(int i=0;i<SIZE;++i) while(isspace(s[i]=getchar()));
return;
}
inline void write(){
for(int i=0;i<SIZE;++i) putchar(s[i]);
return;
}
inline bool valid(){
int cnt[NUM]={0},tmp;
for(int i=0;i<SIZE;++i){
if(grn[i]){
if(s[i]==grn[i]) continue;
else return 0;
}
tmp=(unsigned char)s[i]-OFFSET;
if(!v[tmp]) continue;
if(y[tmp][i]) return 0;
++cnt[tmp];
if(cnt[tmp]>a[tmp]) return 0;
}
return 1;
}
friend inline bool operator<(const wrd x,const wrd y){
for(int i=0;i<SIZE;++i){
if(x.s[i]>y.s[i]) return 0;
else if(x.s[i]<y.s[i]) return 1;
}
return 0;
}
};
int main(){
scanf("%d%d",&N,&W);
do{
wrd g,f;
int cnt[NUM]={0},tmp;
g.read();
f.read();
for(int i=0;i<SIZE;++i){
tmp=(unsigned char)g.s[i]-OFFSET;
v[tmp]=1;
switch(f.s[i]){
case 'G':{
grn[i]=g.s[i];
break;
}
case 'Y':{
y[tmp][i]=1;
++cnt[tmp];
break;
}
}
}
for(int i=0;i<NUM;++i) a[i]=max(a[i],cnt[i]);
}
while(--N);
do{
wrd g;
g.read();
if(g.valid()){
g.write();
putchar('\n');
}
}
while(--W);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 1560kb
input:
2 5 BERRY -G--- APPLE ---YY MELON BERRY LEMON LIMES APPLE
output:
MELON LEMON
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 1888kb
input:
3 5 BERRY -G--- APPLE ---YY LIMES G-GY- APPLE BERRY LEMON LIMES MELON
output:
LEMON
result:
ok single line: 'LEMON'
Test #3:
score: 0
Accepted
time: 0ms
memory: 1700kb
input:
3 5 BLANK --Y-- SIGHS ----G STORM YGG-Y ATOMS BLANK MOATS SIGHS STORM
output:
ATOMS
result:
ok single line: 'ATOMS'
Test #4:
score: 0
Accepted
time: 0ms
memory: 1484kb
input:
4 5 FRUIT -G--Y NUTTY --Y-- ROOTS Y--YG SEEDS -YG-G FRUIT NUTTY ROOTS SEEDS TREES
output:
TREES
result:
ok single line: 'TREES'
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 1752kb
input:
4 8916 ALPHA ----G GAMMA Y--GG DELTA ----G OMEGA -Y-YG AAHED AALII AARGH ABACA ABACI ABACK ABAFT ABAKA ABAMP ABASE ABASH ABATE ABAYA ABBAS ABBES ABBEY ABBOT ABEAM ABELE ABETS ABHOR ABIDE ABLED ABLER ABLES ABMHO ABODE ABOHM ABOIL ABOMA ABOON ABORT ABOUT ABOVE ABRIS ABUSE ABUTS ABUZZ ABYES ABYSM ABYSS...
output:
SIGMA SUMMA
result:
wrong output format Extra information in the output file