QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#54982 | #2971. Wordle with Friends | abdelrahman001# | WA | 6ms | 7172kb | C++ | 1.5kb | 2022-10-11 20:02:58 | 2022-10-11 20:03:00 |
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 = 5e4 + 5;
int n, m;
string s[15], feedback[15];
vector<pair<int, string>> ans;
int trie[N][26];
int mark[N], id = 1;
void add(string s, int i) {
int v = 0;
for(auto j : s) {
int c = j - 'A';
if(!trie[v][c])
trie[v][c] = id++;
v = trie[v][c];
}
mark[v] = i;
}
void solve(int i, int v, string cur) {
if(i == 5) {
for(int k = 0;k < n;k++) {
map<char, int> tmp, now;
for(int j = 0;j < 5;j++) {
if((feedback[k][j] == '-' || feedback[k][j] == 'Y') && cur[j] == s[k][j])
return;
else if(feedback[k][j] == 'G' && cur[j] != s[k][j])
return;
if(feedback[k][j] == 'Y')
tmp[s[k][j]]++;
now[cur[j]]++;
}
for(auto j : tmp)
if(now[j.first] < j.second)
return;
}
ans.push_back({mark[v], cur});
return;
}
for(char c = 'A';c <= 'Z';c++)
if(trie[v][c - 'A'])
solve(i + 1, trie[v][c - 'A'], cur + c);
}
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> m;
for(int i = 0;i < n;i++)
cin >> s[i] >> feedback[i];
for(int i = 0;i < m;i++) {
string w;
cin >> w;
add(w, i);
}
solve(0, 0, "");
sort(ans.begin(), ans.end());
for(auto i : ans)
cout << i.second << '\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5560kb
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: 3520kb
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: 2ms
memory: 5624kb
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: 6ms
memory: 7100kb
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: 7172kb
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'