QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#640557 | #7882. Linguistics Puzzle | wzl19371 | WA | 6ms | 3796kb | C++23 | 1.7kb | 2024-10-14 14:17:07 | 2024-10-14 14:17:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
vector<int> cvt(int x, int k) {
vector<int> s;
while(x) {
int c = x % k;
x /= k;
s.push_back(c);
}
if(s.size())
s = vector(s.rbegin(), s.rend());
else
s = {0};
return s;
}
void solve() {
int n;
cin >> n;
int ct[n+5][3] = {};
for(int i=0;i<n;i++) {
for(int j=0;j<n;j++) {
auto vec = cvt(i*j, n);
for(int k=0;k<vec.size();k++) {
ct[vec[k]][k]++;
}
if(vec.size() == 2 && vec[0] == vec[1])
ct[vec[0]][2]++;
}
}
int ct2[n+5][3] = {};
for(int i=1;i<=n*n;i++) {
string s; cin >> s;
for(int k=0;k<s.size();k++) {
if(islower(s[k]))
ct2[s[k]-'a'][k]++;
else
ct2[s[k]-'A'+26][k]++;
}
if(s.size() == 2 && s[0] == s[1])
ct2[s[0] + (islower(s[0]) ? (-'a') : (-'A'+26))][2]++;
}
bool v[n+5] = {};
for(int i=0;i<n;i++) {
for(int j=0;j<n;j++) {
if(v[j]) continue;
bool ok = true;
for(int k=0;k<3;k++) {
if(ct[i][k] != ct2[j][k]) {
ok = false;
break;
}
}
if(ok) {
v[j] = true;
if(j < 26)
cout << char(j + 'a');
else
cout << char(j - 26 + 'A');
break;
}
}
}
cout << '\n';
}
int main() {
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
int t; cin >> t;
while(t--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
2 3 a b a b b b b c cc 4 d d d d d c b a d b cd cb d a cb bc
output:
bca dcba
result:
ok OK
Test #2:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
2 4 d a a bc ba bc b a a a d a a cb c c 4 a b da b b d ad b db b a c da b c b
output:
abcd bdac
result:
ok OK
Test #3:
score: -100
Wrong Answer
time: 6ms
memory: 3568kb
input:
50 3 b b b a a c b b cc 4 d ab c ad d b ba ab c b d d d d d a 5 a aa aa ab ab ae b b e c c c ba c c c c dd d d dd c e c e 6 a ca a a a a a a ce a a b ba ba bc bc bd be e c c ca a cd cd be d d dc dc e e a eb f f 7 a a a a a a a a cf a a a a b b b b c c c cf a dd d dc d dd e f ed ee ee fb eg eg eg eg ...
output:
bca dabc cadbe abcdef aefdcgb fcheabgd bhgfedcia jhcgfideba fjbadkegcih klhgjbaedcif igkjmclfedhba nflijahgmbdcek anmlfijbgkcdheo nofmlkjchdbegipa aponblgjihcfqdkme iqmonhckfrpgjedlba prisodmbkjqghfencla tcrdpoaklmjihfgeqsbn utiraponmlksghjfecdbq qotsrvjunmlkpiegfhdcba pvutsrhwoimlkjnqgfedbca xbvuts...
result:
wrong answer The product 5*11=55 is not in the output at case #13