QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#553556 | #2971. Wordle with Friends | mrandal | WA | 2ms | 3832kb | C++14 | 2.1kb | 2024-09-08 15:24:45 | 2024-09-08 15:24:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
using pll = pair<long long, long long>;
int main(){
int N, W;
cin >> N >> W; //Guesses, guessable words
vector<char> greens(5, '0');
set<char> reds;
vector<set<char>> yellowNonGuesses(5);
multiset<char> yellows;
for(int i = 0; i < N; ++i){
string word, guess;
cin >> word >> guess;
set<char> yellowInWord {};
for(int j = 0; j < 5; ++j){
if(guess[j] == 'G'){
greens[j] = word[j];
yellowInWord.insert(word[j]);
}
else if(guess[j] == 'Y'){
yellowInWord.insert(word[j]);
yellowNonGuesses[j].insert(word[j]);
}
else
reds.insert(word[j]);
}
for(auto it = yellowInWord.begin(); it != yellowInWord.end(); ++it){
while(yellows.find(*it) == yellows.end() || yellows.count(*it) < yellowInWord.count(*it)){
yellows.insert(*it);
}
}
}
for(int i = 0; i < W; ++i){
string word;
cin >> word;
bool flag = false;
multiset<char> used {};
for(int j = 0; j < 5; ++j){
used.insert(word[j]);
if(greens[j] != '0' && greens[j] != word[j]){
flag = true;
break;
}
if(yellowNonGuesses[j].find(word[j]) != yellowNonGuesses[j].end()){
flag = true;
break;
}
}
if(flag) continue;
for(auto it = used.begin(); it != used.end(); ++it){
if(used.count(*it) < yellows.count(*it)){
flag = true;
break;
}
else if(reds.find(*it) != reds.end()){
if(used.count(*it) != yellows.count(*it)){
flag = true;
break;
}
}
}
if(!flag){
cout << word << endl;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3644kb
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: 3612kb
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: 3608kb
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: 3584kb
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: 0
Accepted
time: 2ms
memory: 3540kb
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
result:
ok single line: 'SIGMA'
Test #6:
score: 0
Accepted
time: 2ms
memory: 3640kb
input:
3 8916 SHARP G---- HEART ----- KNACK -G--- 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 ACARI ACERB...
output:
SNIBS SNIFF SNOBS SNOGS SNOOD SNOOL SNOWS SNOWY SNUBS SNUFF SNUGS
result:
ok 11 lines
Test #7:
score: -100
Wrong Answer
time: 2ms
memory: 3832kb
input:
3 8916 MOUNT -G--- AREAS -Y--- KICKS --GG- 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 ACARI ACERB...
output:
COCKY JOCKO POCKY ROCKY
result:
wrong answer 1st lines differ - expected: 'ROCKY', found: 'COCKY'