QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#745789 | #5603. Three Dice | i24 | TL | 855ms | 3860kb | C++14 | 4.6kb | 2024-11-14 11:39:41 | 2024-11-14 11:39:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n;
cin >> n;
vector<int> a(26);
vector<string> S(n);
bool flag = false;
for(int i = 0; i < n; ++i) {
string x;
cin >> x;
if (x[0] == x[1] || x[1] == x[2] || x[2] == x[0]) flag = true;
a[x[0] - 'a'] = 1;
a[x[1] - 'a'] = 1;
a[x[2] - 'a'] = 1;
S[i] = x;
}
int sum = 0;
for(int i = 0; i < 26; ++i) sum += a[i];
if (flag || sum > 18) {cout << 0 << "\n"; return 0;}
for(int i = 0; i < 26 && sum < 18; ++i) {
if (a[i] == 0) {a[i] = 1; sum++;}
}
vector<char> b;
map<char, int> m;
for(int i = 0; i < 26; ++i) if (a[i] == 1) {b.push_back('a' + i); m['a' + i] = b.size() - 1;}
for (int x1 = 0; x1 < 13; ++x1) {
for (int x2 = x1 + 1; x2 < 14; ++x2) {
for (int x3 = x2 + 1; x3 < 15; ++x3) {
for(int x4 = x3 + 1; x4 < 16; ++x4) {
for(int x5 = x4+1; x5 < 17; ++x5) {
for(int x6 = x5+1; x6 < 18; ++x6) {
set<char> s1;
s1.insert(x1);
s1.insert(x2);
s1.insert(x3);
s1.insert(x4);
s1.insert(x5);
s1.insert(x6);
for (int y1 = 1; y1 < 13; ++y1) {
if (s1.count(y1)==1) continue;
for(int y2 = y1 +1; y2 < 14; ++y2) {
if (s1.count(y2) == 1) continue;
for(int y3 = y2+1; y3 < 15; ++y3) {
if (s1.count(y3) == 1) continue;
for(int y4 = y3+1; y4 <16; ++y4) {
if (s1.count(y4)==1) continue;
for(int y5 = y4+1; y5 < 17; ++y5) {
if (s1.count(y5)==1) continue;
for(int y6=y5+1; y6 < 18; ++y6) {
if (s1.count(y6) == 1) continue;
set<char> s2;
s2.insert(y1);
s2.insert(y2);
s2.insert(y3);
s2.insert(y4);
s2.insert(y5);
s2.insert(y6);
bool work = true;
for(string& v: S) {
int X = 0, Y = 0;
for(char& c: v)
if (s1.count(m[c])==1) X++;
else if (s2.count(m[c])==1) Y++;
if (X != 1 || Y != 1) {work = false; break;}
}
if (work) {
string ok1 = string(1, b[x1]) + b[x2] + b[x3] + b[x4] + b[x5] + b[x6];
string ok2 = string(1, b[y1]) + b[y2] + b[y3] + b[y4] + b[y5] + b[y6];
string ok3 = "";
for(int z = 0; z < 18; ++z)
if (s1.count(z)==0 && s2.count(z)==0)
ok3 = ok3 + b[z];
cout << ok1 << " " << ok2 << " " << ok3 << "\n";
return 0;
}
}
}
}
}
}
}
}
}
}
}
}
cout << "0\n"; return 0;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 17ms
memory: 3556kb
input:
3 lad fin sly
output:
abcefs dghijy klmnop
result:
ok correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
1 dad
output:
0
result:
ok impossible
Test #3:
score: 0
Accepted
time: 63ms
memory: 3492kb
input:
11 aft cog far irk kit yes tau rag own uke via
output:
abckns deortv fgiuwy
result:
ok correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3652kb
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: 0ms
memory: 3608kb
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: 0ms
memory: 3584kb
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: 202ms
memory: 3860kb
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: 855ms
memory: 3652kb
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: 471ms
memory: 3652kb
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: 504ms
memory: 3612kb
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: 738ms
memory: 3632kb
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: -100
Time Limit Exceeded
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 ...