QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#43067 | #2971. Wordle with Friends | sinbad# | AC ✓ | 4ms | 3752kb | C++ | 4.6kb | 2022-08-06 10:25:03 | 2022-08-06 10:25:06 |
Judging History
answer
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const multiset<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
template <class T> auto vect(const T& v, int n) { return vector<T>(n, v); }
template <class T, class... D> auto vect(const T& v, int n, D... m) {
return vector<decltype(vect(v, m...))>(n, vect(v, m...));
}
using int64 = long long;
using int128 = __int128_t;
using ii = pair<int, int>;
#define SZ(x) (int)((x).size())
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
mt19937_64 mrand(random_device{}());
int64 rnd(int64 x) { return mrand() % x; }
int lg2(int64 x) { return sizeof(int64) * 8 - 1 - __builtin_clzll(x); }
template <class T> void out(const vector<T>& a) { for (int i = 0; i < SZ(a); ++i) cout << a[i] << " \n"[i + 1 == SZ(a)]; }
template <class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template <class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template <class T> void dedup(vector<T>& v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); }
void add_mod(int& x, int y) { x += y; if (x >= MOD) x -= MOD; }
void sub_mod(int& x, int y) { x += MOD - y; if (x >= MOD) x -= MOD; }
struct fast_ios {
fast_ios() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
};
} fast_ios_;
int main() {
int n, m;
cin >> n >> m;
vector<string> a(n), b(n);
for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
auto solve =
[&](const string& hidden, const string& guess) {
string ret(5, '-');
vector<bool> visH(5), visG(5);
for (int i = 0; i < 5; ++i) {
if (hidden[i] == guess[i]) {
ret[i] = 'G';
visH[i] = visG[i] = 1;
}
}
for (int i = 0; i < 5; ++i) {
if (visG[i]) continue;
for (int j = 0; j < 5; ++j) {
if (visH[j]) continue;
if (guess[i] == hidden[j]) {
ret[i] = 'Y';
visG[i] = visH[j] = 1;
break;
}
}
}
// trace(hidden, guess, ret);
return ret;
};
for (int i = 0; i < m; ++i) {
string s;
cin >> s;
bool ok = 1;
for (int i = 0; i < n; ++i) {
if (solve(s, a[i]) != b[i]) {
ok = 0;
break;
}
}
if (ok) cout << s << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3700kb
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: 3576kb
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: 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: 3516kb
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: 3ms
memory: 3568kb
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: 3ms
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:
SNIBS SNIFF SNOBS SNOGS SNOOD SNOOL SNOWS SNOWY SNUBS SNUFF SNUGS
result:
ok 11 lines
Test #7:
score: 0
Accepted
time: 3ms
memory: 3648kb
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:
ROCKY
result:
ok single line: 'ROCKY'
Test #8:
score: 0
Accepted
time: 3ms
memory: 3580kb
input:
3 8916 IRATE Y--G- STAIR YY-Y- RAISE --YY- 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:
BINTS BITTS CISTS DINTS FISTS GIFTS GILTS GISTS HILTS HINTS HISTS JILTS KILTS KISTS LIFTS LILTS LINTS LISTS MILTS MINTS MISTS MISTY MITTS PINTS TILTS TINTS WILTS WISTS XYSTI
result:
ok 29 lines
Test #9:
score: 0
Accepted
time: 3ms
memory: 3556kb
input:
3 8916 HONOR ----Y HELPS ----Y SERVE Y-Y-- 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:
ARTSY BRISK BRUSK CRUST FRISK GRIST RISKY RUSTY TRUST TRYST URSID USURY WRIST
result:
ok 13 lines
Test #10:
score: 0
Accepted
time: 2ms
memory: 3752kb
input:
1 10000 BBBBB ----- OIFHE IAGRK SXKHT ULOQD EZLIW TOCWV TDQWF ZPFET DWOGL KFEHQ SCWIC PMQDH RRMHA MGOWZ APWRI WGRCR WVZKQ TTHPB EXMYJ SEAPE XGYGI ETGTJ IZEOF JSLAP EDGTL HNOOT LOTNF VKLSK OJVXU MLCSV MJSUG SCAME DKHXC LRUNF NENUW TPZGL CLOCY MGRTN FFTMJ VVTYL DEHIU ARPNK UPOIH ULCOF MKUKB SDFVC SFCF...
output:
OIFHE IAGRK SXKHT ULOQD EZLIW TOCWV TDQWF ZPFET DWOGL KFEHQ SCWIC PMQDH RRMHA MGOWZ APWRI WGRCR WVZKQ EXMYJ SEAPE XGYGI ETGTJ IZEOF JSLAP EDGTL HNOOT LOTNF VKLSK OJVXU MLCSV MJSUG SCAME DKHXC LRUNF NENUW TPZGL CLOCY MGRTN FFTMJ VVTYL DEHIU ARPNK UPOIH ULCOF SDFVC SFCFW FAONH WUEVJ SYCXM XQFCH OTSOU ...
result:
ok 8229 lines
Test #11:
score: 0
Accepted
time: 4ms
memory: 3656kb
input:
10 10000 CYHKU ----G AQGTO --Y-- KYYHX ----Y DPPIY ----- RLDPC -G--- LBRPO Y---- PXYBV -Y--- KODRL ----Y PWIIL ----Y ZIOXR ---Y- QELBH TCSWH ZQBGA OETEQ GCSWJ VSMOO QPKBP ONAKY DSRBY QGZNV ACCOH WCQBD FOAFL ZUADN JUIEV YTKTJ DXBPD ZISLO PQWVY XXGUV FRIAP DEMQW AACXN UEUOG RPEDY LBKOA NWWIX LJDFJ SSO...
output:
GLXJU
result:
ok single line: 'GLXJU'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3552kb
input:
2 3 WHITE ----- GREEN ----- BLACK GREEN WHITE
output:
BLACK
result:
ok single line: 'BLACK'
Test #13:
score: 0
Accepted
time: 2ms
memory: 3628kb
input:
2 3 BLACK GGGGG GREEN ----- BLACK GREEN WHITE
output:
BLACK
result:
ok single line: 'BLACK'
Test #14:
score: 0
Accepted
time: 2ms
memory: 3520kb
input:
2 8916 WHITE ----- GREEN ----- 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 ACETA ACHED...
output:
ABACA ABACK ABAKA ABAMP ABAYA ABBAS ABOMA ABUZZ ABYSM ABYSS ACOCK ACOLD ACYLS ADDAX ADOBO AFOAM AFOUL ALACK ALAMO ALBAS ALBUM ALDOL ALFAS ALKYD ALKYL ALLAY ALLOD ALLOY ALLYL ALMAS ALMUD ALOOF ALOUD ALULA ALUMS AMASS AMBOS AMMOS AMOKS AMPLY AMPUL AMUCK AMYLS APODS APPAL APPLY AQUAS ASCUS ASKOS ASSAY ...
result:
ok 762 lines
Test #15:
score: 0
Accepted
time: 3ms
memory: 3632kb
input:
2 8916 BLACK GGGGG GREEN ----- 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 ACETA ACHED...
output:
BLACK
result:
ok single line: 'BLACK'
Test #16:
score: 0
Accepted
time: 3ms
memory: 3692kb
input:
2 8916 STARE YYGGY FISHY --Y-- 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 ACETA ACHED...
output:
TEARS
result:
ok single line: 'TEARS'
Test #17:
score: 0
Accepted
time: 2ms
memory: 3632kb
input:
1 1 HELLO GGGGG HELLO
output:
HELLO
result:
ok single line: 'HELLO'
Test #18:
score: 0
Accepted
time: 3ms
memory: 3740kb
input:
5 8916 SPLAT ----- CARES ----- TENIA --GY- LIROT -G--- STELA ----- SPLAT CARES TENIA LIROT STELA DINGY THERM BORTS SNARL SATED ANGER CELTS PLAIN PUCES SOKES EDIFY FRITT ACIDS CUSSO RECUR MENAD JORAM GORSE TRULL HOWES FATLY TALON MOLAR CARTS BEGAN BAFFS CULMS KLIKS NIPAS ODIST MIZEN AGAIN IDYLL BONDS...
output:
DINGY FINNY WINGY JINNI DINKY GINNY MINNY NINNY WINDY KINKY ZINGY BINDI MINGY HINKY HINNY ZINKY
result:
ok 16 lines
Test #19:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
5 8916 PULER -GG-- GRABS G---- TREND ----- NEMAS ----- ANNUL ---YY PULER GRABS TREND NEMAS ANNUL GULCH CAGEY RERUN TABOO LIVID RIFFS KALES SALAD RELET POOHS WENCH PUTTO CALMS LYARD SPOON FUSIL GRIFF MONGO LEZZY QUATE BOOMS KNISH JEHUS SOILS MACES BELON MOLTS TWYER COZEN GAVOT REEFS HYDRO ASKEW DATES...
output:
GULCH GULLY GULFY
result:
ok 3 lines
Test #20:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
2 8916 JURAT --GY- CURIE G-G-Y JURAT CURIE CAREX BIBBS PALEA OPERA RAJAH EMERY CREEL OSTIA REVET ROWDY SPRIG AZUKI CHASM FOAMY PRIES BELCH LINKY DRUBS INFIX TUBBY FIQUE MEDIA SOAVE EIDOS STEWS USQUE UREAS CHAYS ISLED RAKEE LAHAR SWART CUBER KEVEL LIFTS SPAHI SWARD SLICK PUNTS YOKES CORIA VISIT SAYER...
output:
CAREX CARER CARED CARES
result:
ok 4 lines
Test #21:
score: 0
Accepted
time: 4ms
memory: 3752kb
input:
4 8916 CHUCK ----- GRANS ----- KARMA ----- TEGUA -G--- CHUCK GRANS KARMA TEGUA DELLY DOATS OUZOS SOPHY DREED WHIST KEIRS PENAL GASPS DRIES ROMAN FROTH SHALT LOOPS PRAUS HARPY ANNOY LUTES BLARE SOPOR PAINS APEAK DEVIL RECTI VALUE MINTY DYING WIMPS JATOS WALLA ZLOTY POSER FOEHN CACTI SHOJI UNIFY GEOID...
output:
DELLY DEVIL BEVEL FEDEX VEXED BEEDI JELLO DEWED VEXIL FEYLY WEDEL PEPPY WEEPY WEBBY LEVEL BELIE JELLY BEZEL BEBOP BELLY WELLY DELED BEDEW PEWEE DEVEL DEIFY BEZIL JEWEL FEEZE DELVE PEEVE BELOW BEEFY DEBYE WEEDY FELID FEOFF DEOXY DEXIE LEVEE LEZZY JEBEL DEEDY BELLE FEZZY BEDEL FELLY
result:
ok 47 lines
Test #22:
score: 0
Accepted
time: 3ms
memory: 3576kb
input:
6 8916 IVORY Y---G JIFFS -Y-G- GURRY -Y--G DONGS --Y-- CHIAO --G-- POXES ----- IVORY JIFFS GURRY DONGS CHIAO POXES UNIFY SMEEK RAWER MONAD MARLS PIRNS WHACK STALL LILAC CACTI GRAPH TACES CHIEL LEHRS URSID CURSE GRIPE PRISM TRYMA HEATH HARES ABLER BIGOS POSSE FORTE IRONE SWAMP KINKY WARDS BYSSI POCKY...
output:
UNIFY
result:
ok single line: 'UNIFY'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
10 8916 BLOGS YG--G ZEBRA --G-Y SHIEL Y---Y SONSY Y---- KELLY --Y-- YOURS ----G SORRY Y---- DOCKS ----G DYNES ----G MAXIS -Y--G BLOGS ZEBRA SHIEL SONSY KELLY YOURS SORRY DOCKS DYNES MAXIS ALBAS ANILE LIANE CHOOK HEXER PALER GENET CULPA HELVE PAGED OAKEN PATCH GAUMS NOLOS NABES JOIST FERES ARDEB SWOR...
output:
ALBAS
result:
ok single line: 'ALBAS'