QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#54877#2971. Wordle with FriendsMostafa_Moharram#AC ✓3ms3940kbC++171.7kb2022-10-11 03:40:262022-10-11 03:40:29

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-11 03:40:29]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3940kb
  • [2022-10-11 03:40:26]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

struct Guess {
    string w, feed;
    bool check(const string &word) {
        int cnt[26]{};
        for (char c : word)
            ++cnt[c - 'A'];
        const int n = (int) word.size();
        for (int i = 0; i < n; ++i) {
            if (word[i] == w[i]) {
                --cnt[word[i] - 'A'];
                if (feed[i] == 'G')
                    continue;
                return false;
            }
            if (feed[i] == 'G')
                return false;
        }
        for (int i = 0; i < n; ++i) {
            if (feed[i] == 'G') continue;
            if (cnt[w[i] - 'A'] == 0) {
                if (feed[i] == '-')
                    continue;
                return false;
            }
            if (feed[i] == 'Y') {
                if (cnt[w[i] - 'A'] == 0)
                    return false;
                cnt[w[i] - 'A'] = 0;
                continue;
            }
            if (cnt[w[i] - 'A'] != 0)
                return false;
        }
        return true;
    }
};

int main() {
    ios::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr);
    int n, w;
    cin >> n >> w;
    vector<Guess> guesses(n);
    for (Guess &guess : guesses)
        cin >> guess.w >> guess.feed;
    vector<string> ans;
    for (int _ = 0; _ < w; ++_) {
        string word; cin >> word;
        bool add = true;
        for (auto &guess : guesses)
            if (not guess.check(word)) {
                add = false; break;
            }
        if (add) ans.emplace_back(word);
    }
    for (const auto &w : ans)
        cout << w << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3724kb

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: 3560kb

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: 3500kb

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: 1ms
memory: 3620kb

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: 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: 0
Accepted
time: 3ms
memory: 3680kb

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: 3500kb

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: 1ms
memory: 3552kb

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: 3632kb

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: 1ms
memory: 3940kb

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: 3ms
memory: 3560kb

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: 2ms
memory: 3648kb

input:

2 3
WHITE -----
GREEN -----
BLACK
GREEN
WHITE

output:

BLACK

result:

ok single line: 'BLACK'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

2 3
BLACK GGGGG
GREEN -----
BLACK
GREEN
WHITE

output:

BLACK

result:

ok single line: 'BLACK'

Test #14:

score: 0
Accepted
time: 1ms
memory: 3688kb

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: 3636kb

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: 3636kb

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: 3728kb

input:

1 1
HELLO GGGGG
HELLO

output:

HELLO

result:

ok single line: 'HELLO'

Test #18:

score: 0
Accepted
time: 3ms
memory: 3648kb

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: 3ms
memory: 3684kb

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: 3572kb

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: 3ms
memory: 3568kb

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: 2ms
memory: 3556kb

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: 3ms
memory: 3568kb

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'