QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#31384 | #2971. Wordle with Friends | mx | WA | 5ms | 3696kb | C++ | 2.1kb | 2022-05-07 19:53:05 | 2022-05-07 19:53:07 |
Judging History
answer
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
//----------------------------------------------------------------
int main() {
int n, w;
string t, result, guess;
vector<string> black(5), white(5), ex(5);
unordered_map<char, int> inc;
cin >> n >> w;
for (int i = 0; i < n; i++) {
cin >> t >> result;
unordered_map<char, int> temp_map;
for (int j = 0; j < 5; j++) {
if (result[j] == '-') {
black[j] += t[j];
}
if (result[j] == 'G') {
white[j] += t[j];
temp_map[t[j]]++;
}
if (result[j] == 'Y') {
ex[j] += t[j];
temp_map[t[j]]++;
}
}
for (auto iter = temp_map.begin(); iter != temp_map.end(); ++iter) {
inc[iter->first] = max(iter->second, inc[iter->first]);
}
}
for (int i = 0; i < w; i++) {
cin >> guess;
bool flag = true;
unordered_map<char, int> inc_test = inc;
/*cout << "Checking" << guess << endl;
for (auto iter = inc_test.begin(); iter != inc_test.end(); ++iter) {
cout << iter->first << " " << iter->second << endl;
}
cout << "Checking end" << endl;*/
for (int j = 0; j < 5; j++) {
if (black[j].find(guess[j]) != std::string::npos ||
ex[j].find(guess[j]) != std::string::npos) {
flag = false;
break;
}
if (white[j].size() > 0) {
if (white[j][0] != guess[j]) {
flag = false;
break;
}
}
auto search = inc_test.find(guess[j]);
if (search != inc_test.end()) {
inc_test[guess[j]]--;
if (inc_test[guess[j]] < 0) {
flag = false;
break;
}
}
}
for (auto iter = inc_test.begin(); iter != inc_test.end(); ++iter) {
// cout << iter->first << " " << iter->second << endl;
auto cur = iter->second;
if (cur != 0) {
flag = false;
break;
}
}
if (flag) {
cout << guess << endl;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 3652kb
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: 3ms
memory: 3696kb
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: 2ms
memory: 3640kb
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: 3652kb
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: 5ms
memory: 3632kb
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: -100
Wrong Answer
time: 2ms
memory: 3560kb
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:
SNEER SNELL SNIDE SNIFF SNIPE SNOOD SNOOL SNOWY SNUFF
result:
wrong answer 1st lines differ - expected: 'SNIBS', found: 'SNEER'