QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#95755 | #5603. Three Dice | triplem5ds# | AC ✓ | 2ms | 3660kb | C++20 | 2.7kb | 2023-04-11 19:56:38 | 2023-04-11 19:56:40 |
Judging History
answer
///Enta etfsh5t nseet el rank
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
tree_order_statistics_node_update>;
#define pb push_back
#define F first
#define S second
#define f(i, a, b) for (int i = a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
//#define mp(x, y) make_pair(x, y)
#define popCnt(x) (__builtin_popcountll(x))
#define int ll
using ll = long long;
using ull = unsigned long long;
using uint = uint32_t;
using ii = pair<int, int>;
const int N = 1e5 + 20, LG = 18, MOD = (119 << 23) + 1;
const long double PI = acos(-1);
const long double EPS = 1e-9;
string s[1005];
vector<int> adj[256];
string toAssign;
int col[256];
int cnt[3];
void bt(int index) {
if (index == toAssign.size()) {
string s[3];
f(i, 0, 18)s[col[toAssign[i]]].push_back(toAssign[i]);
cout << s[0] << ' ' << s[1] << ' ' << s[2] << endl;
::exit(0);
}
bool can[3] = {cnt[0] != 6, cnt[1] != 6, cnt[2] != 6};
for (auto x: adj[toAssign[index]])
if (col[x] != -1) {
can[col[x]] = false;
}
f(i, 0, 3)
if (can[i]) {
col[toAssign[index]] = i;
cnt[i] += 1;
bt(index + 1);
cnt[i] -= 1;
}
col[toAssign[index]] = -1;
}
void doWork() {
::memset(col, -1, sizeof col);
int n;
cin >> n;
set<char> st;
f(i, 0, n) {
cin >> s[i];
st.insert(s[i][0]);
st.insert(s[i][1]);
st.insert(s[i][2]);
}
if (st.size() > 18) {
cout << "0\n";
return;
}
f(i, 0, n) {
if (s[i][0] == s[i][1] || s[i][0] == s[i][2] || s[i][1] == s[i][2]) {
cout << "0\n";
return;
}
f(j, 0, 3)
f(k, 1, 3)
adj[s[i][j]].push_back(s[i][k]),
adj[s[i][k]].push_back(s[i][j]);
}
for (char c: st)toAssign.push_back(c);
for (char c = 'a'; c <= 'z' && toAssign.size() < 18; c++) {
if (st.count(c))continue;
toAssign.push_back(c);
}
bt(0);
cout << "0\n";
}
int32_t main() {
#ifdef ONLINE_JUDGE
ios_base::sync_with_stdio(0);
cin.tie(0);
#endif // ONLINE_JUDGE
int t = 1;
// cin >> t;
while (t--)
doWork();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3464kb
input:
3 lad fin sly
output:
afsbce diyghj lnkmop
result:
ok correct
Test #2:
score: 0
Accepted
time: 2ms
memory: 3392kb
input:
1 dad
output:
0
result:
ok impossible
Test #3:
score: 0
Accepted
time: 2ms
memory: 3452kb
input:
11 aft cog far irk kit yes tau rag own uke via
output:
acknsb eortvd fgiuwy
result:
ok correct
Test #4:
score: 0
Accepted
time: 2ms
memory: 3444kb
input:
20 aah aal aas aba abo abs aby ace act add ado ads adz aff aft aga age ago aha aid
output:
0
result:
ok impossible
Test #5:
score: 0
Accepted
time: 2ms
memory: 3396kb
input:
23 abc acb bac bca cab cba abd adb bad bda dab dba acd adc cad cda dac dca fgh ijk lmn opq rst
output:
0
result:
ok impossible
Test #6:
score: 0
Accepted
time: 1ms
memory: 3480kb
input:
24 abc bcd cde def efg fgh ghi hij ijk jkl klm lmn mno nop opq pqr qrs rst stu tuv uvw vwx wxy xyz
output:
0
result:
ok impossible
Test #7:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
121 lax tog taj fun get jar fez own now gut gul ark fax new meg fen fog log lez gum kor leg not rug fug lag kit urn gal nam gar jew rex rin ant gam mun jam nil gem kir ilk jut ern man mon awn mig mix wag erg gor fig run nim raj fix elk nom wig gat nor jow fag jaw kaf rig fin kat rag mag won wog wan ...
output:
aeiouy flmrtw gjknxz
result:
ok correct
Test #8:
score: 0
Accepted
time: 2ms
memory: 3488kb
input:
149 pic twa cub wag spa til two pyx pis tew vug cig pul vig pol tow tis sub pew sty eld gas pes guv bal dol lob sot sap cob ply tic taw wit bow lad gal cup cep pax lab bys sup psi pox ops tel dex veg lop vat uts ods ups wiz lit gox wud cad sod cud dev paw pac dow wig gul zax sob set lag lip doc bos ...
output:
aeiouy bdgptz clsvwx
result:
ok correct
Test #9:
score: 0
Accepted
time: 2ms
memory: 3484kb
input:
97 fub tav seg box tas ski bin six syn fas sag neb sot jog gab van vug zax ban fob ons ask zit jot zin jin fiz nob jut fez beg vet sox kos gib sit sat bun bot son ifs ens but fib ins bug big sen vig tab sex zig ben sin efs kas kob nos zek nab qat xis gob guv set its bag sun veg zag uns tis sty ska n...
output:
aeiouy bjqsvz fgkntx
result:
ok correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
150 jug nit hen ant imp men ply pam pah awn jig god pal pet gan put jet dol zag tap ted lip dah lez tad pom dom dig pul hup mod edh poh dow lop old wan hap wed gin tup paw tod wiz nil ton nom tan hun hin apt mop daw pol ump noh pew pot wap hid nut map lap gun tun nam gip won nag eng wad own zit mon ...
output:
aeiouy djnpqz ghlmtw
result:
ok correct
Test #11:
score: 0
Accepted
time: 2ms
memory: 3508kb
input:
259 bog ant gan urn eng pit pig dam bid nod dap rib pul ens bot dim fur ops fad ugh fag bod hes lib she spy rep rum ash mug lin mig tan het rif sop pur gap bet pal mud big dah bit gun fro arm rub dib rap fed oms bas alb aft lip mol ins fas gum sob mod end ref sib dip arf mos ems hut nor ifs bra bud ...
output:
aeiouy bfhmnp dglrst
result:
ok correct
Test #12:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
260 bog ant gan urn eng pit pig dam bid nod dap rib pul ens bot dim fur ops fad ugh fag bod hes lib she spy rep rum ash mug lin mig tan het rif sop pur gap bet pal mud big dah bit gun fro arm rub dib rap fed oms bas alb aft lip mol ins fas gum sob mod end ref sib dip arf mos ems hut nor ifs bra bud ...
output:
0
result:
ok impossible
Test #13:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
1000 lgk nur wnm czr zuk une kob elg whc evn vlx woz mne gnp odp vkz xgz wdc npu hgk ged mwd hvx crn zcr vnp uze xbv brv bve okl bwg kno xgl oeh dec kvh nvp mpz hwc pbc ngk egz zpv zme ubx hgr xbo bgw brc rmd ubp xdc mxh hxc ebu vpz bgk dwg dve deu obp ohw ubx cxl edo zkv mbr mhe kbo zwu zwv gnk rhv...
output:
bdhlnz cgmouv ekprwx
result:
ok correct
Test #14:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
1000 sfp fbk nfw pfk qdk odm wgv kvt nwu mgw ucs gcq gvw kjd mda fod psu jto aqb pmg jba tja kdj usd fbs gqd ckq uod vco mkc djs sbj psj boj mws obu bau bgf qbn atu ntv ncf tof jts cmg tku fac dkf pfs pkf pqa nuw ojc svp otm sbf jwk mac vsp jbs jab dam omt udo jdo dsu joc auw tqs stf vgt cgu psu nup...
output:
agknos bcdptw fjmquv
result:
ok correct
Test #15:
score: 0
Accepted
time: 2ms
memory: 3656kb
input:
1000 zjh lxd ftq xkb xkb oqt clf yce fjq ylc vqy ckv cke ovh fvx xdb qft dwl wjo kqv yei vfi tcf wjd tck ibz lck jcf qvz lzq ezx yvw jif tfq fxe vxz ekc tfi tiz ilz fjw yxj yvx hze dhe ibf ehk qzl kbc yvc oxb oil ijf vfw bkh lhd bhz dhe ybc ybh eyq dbw vxf xlz jwk zjx xkt ivd bio feh yjx ywb wkl xjd...
output:
bejltv chiqwx dfkoyz
result:
ok correct
Test #16:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
1000 epn vpq xud gjq pxr hgt ezo gfs okk ukb rne iof eko flg yzz sck qwa zks bep uzh onw nfs ram tfp ctr ahw hrz fxx jgb izx gvs afn cii vbk wzx lkb sbl dga jpi nlv eon svd ioo zas bgh zdj elm aip kmf fta pmh vwr dsj gib yjv hgx ffx tyn crf yao vqm zbm bzu cay rkt jie pgn jms cpd jhd moz ymc ogc bve...
output:
0
result:
ok impossible
Test #17:
score: 0
Accepted
time: 0ms
memory: 3448kb
input:
1000 dzq bjt xwu pwy mba ekg pyo mqc nqo xrh ptt ayg ogv uga qop olo ohw rrm ekg vwq ilv emx lld ibf hpd ffn kei wop mxx quw zgn otm fcu ehs mnl evl lsk ocr bkg bpc zzx dcm jpx yak yuc qzz ktl ifb blo ktn qpm gtb nhp pao ugp qow hgt wqi axf rjz tnl rtm nyw bmx nfe rfu wru mpw wmm wzy jgm icz szd elb...
output:
0
result:
ok impossible
Test #18:
score: 0
Accepted
time: 2ms
memory: 3496kb
input:
1000 xzy hta jca xfn hjh ige fch cdl tzj gyg qsg ebt irn lys jgs bpe zog mkv ggb wos faa arr sqy cjc bbz wld rkx hdk gob ars frk ltj dzw ilg gxs ubm edf uur yfr fkv pma tek qqe tgn wwh low fit tzz txv yhq xix mnb ner jup nrl bim iwu rgh ohv mmn utv zil wqd vee ajh jwq eau rrh bdc zzm zfk ago bwi cwi...
output:
0
result:
ok impossible