QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#413610 | #7882. Linguistics Puzzle | k1nsom | WA | 1ms | 3800kb | C++17 | 2.2kb | 2024-05-17 20:00:09 | 2024-05-17 20:00:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define N 300005
#define endl '\n'
#define PII pair<int, int>
int n;
string s;
map<char, int> vis[2], cnt[2];
map<PII, queue<char>> zm;
map<int, queue<char>> mz;
map<char, char> ot;
map<char, bool> chk;
char getchr(int x)
{
if (x < 26)
return x + 'a';
return x - 26 + 'A';
}
void solve()
{
for (int i = 0; i <= 1; i++)
{
vis[i].clear();
cnt[i].clear();
}
ot.clear();
zm.clear();
mz.clear();
chk.clear();
cin >> n;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
{
cin >> s;
int tmp = s.size();
tmp--;
for (int j = 0; s[j]; j++)
vis[tmp - j][s[j]]++;
}
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
{
int gw = (i * j) % n, sw = (i * j) / n;
cnt[0][getchr(gw)]++;
if (sw)
cnt[1][getchr(sw)]++;
}
/*for (auto [c, js] : cnt[0])
cout << c << ' ' << js << endl;
for (auto [c, js] : cnt[1])
cout << c << ' ' << js << endl;
cout << "===================\n";
for (auto [c, js] : vis[0])
cout << c << ' ' << js << endl;
for (auto [c, js] : vis[1])
cout << c << ' ' << js << endl;*/
for (auto [c, js] : cnt[0])
if (!chk[c] && js)
{
zm[{js, cnt[1][c]}].push(c);
chk[c] = 1;
}
for (auto [c, js] : cnt[1])
if (!chk[c] && js)
{
mz[js].push(c);
chk[c] = 1;
}
chk.clear();
for (auto [c, js] : vis[0])
if (!chk[c] && js)
{
ot[zm[{js, vis[1][c]}].front()] = c;
zm[{js, vis[1][c]}].pop();
chk[c] = 1;
}
for (auto [c, js] : vis[1])
if (!chk[c] && js)
{
ot[mz[js].front()] = c;
mz[js].pop();
chk[c] = 1;
}
for (auto [c, s] : ot)
cout << s;
cout << endl;
}
signed main()
{
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3484kb
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: 3780kb
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: 0ms
memory: 3800kb
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 anmlfijbgkhdceo nofmlkjchdbegipa aponblgjihcfqdkme iqmonhckfrpgjedlba prisdombkjqghfencla tcrdpoaklmjihfgeqsbn utiraponmlksghjfecdbq qotsrvjunmlkpiegfhdcba pvutsrhwoimlkjnqgfedbca xbvuts...
result:
wrong answer The product 2*12=24 is not in the output at case #17