QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#54941 | #2971. Wordle with Friends | abdelrahman001# | WA | 87ms | 4280kb | C++ | 1.5kb | 2022-10-11 18:04:21 | 2022-10-11 18:04:23 |
Judging History
answer
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 1e3 + 5;
int n, m;
char p[5];
set<char> np[5];
map<char, int> mx;
map<string, int> mp;
vector<pair<int, string>> ans;
void solve(int i, string cur) {
if(i == 5) {
map<char, int> tmp;
for(auto j : cur)
tmp[j]++;
for(auto j : mx) {
if(tmp[j.first] < j.second)
return;
}
if(mp.count(cur))
ans.push_back({mp[cur], cur});
return;
}
if(p[i] != '?')
solve(i + 1, cur + p[i]);
else {
for(char c = 'A';c <= 'Z';c++) {
if(np[i].count(c))
continue;
solve(i + 1, cur + c);
}
}
}
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> m;
for(int i = 0;i < 5;i++)
p[i] = '?';
for(int i = 0;i < n;i++) {
string s, feedback;
cin >> s >> feedback;
map<char, int> f;
for(int j = 0;j < 5;j++) {
if(feedback[j] == 'G') {
f[s[j]]++;
p[j] = s[j];
} else if(feedback[j] == 'Y') {
f[s[j]]++;
mx[s[j]] = max(mx[s[j]], f[s[j]]);
np[j].insert(s[j]);
} else {
for(int k = 0;k < 5;k++)
np[j].insert(s[j]);
}
}
}
for(int i = 0;i < m;i++) {
string s;
cin >> s;
mp[s] = i;
}
solve(0, "");
sort(ans.begin(), ans.end());
for(auto i : ans)
cout << i.second << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 87ms
memory: 3640kb
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: 2ms
memory: 3752kb
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: 1ms
memory: 3560kb
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: 2ms
memory: 3580kb
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: 7ms
memory: 4280kb
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: 3ms
memory: 4280kb
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:
SNEDS SNEER SNELL SNIBS SNIDE SNIFF SNIPE SNIPS SNITS SNOBS SNOGS SNOOD SNOOL SNOTS SNOWS SNOWY SNUBS SNUFF SNUGS SNYES
result:
wrong answer 1st lines differ - expected: 'SNIBS', found: 'SNEDS'