QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#413631 | #7882. Linguistics Puzzle | k1nsom | WA | 9ms | 3812kb | C++17 | 2.7kb | 2024-05-17 20:10:10 | 2024-05-17 20:10:11 |
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[3], cnt[3];
map<PII, queue<char>> zm;
map<int, queue<char>> mz, zzm;
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 <= 2; 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]]++;
if (tmp == 1 && s[0] == s[1])
vis[2][s[0]]++;
}
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)]++;
if (sw && sw == gw)
cnt[2][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[2])
if (!chk[c] && js)
{
zzm[js].push(c);
chk[c] = 1;
}
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 (cnt[0][c] == 0 && js)
{
mz[js].push(c);
chk[c] = 1;
}
chk.clear();
for (auto [c, js] : vis[2])
if (!chk[c] && js)
{
ot[zzm[js].front()] = c;
mz[js].pop();
chk[c] = 1;
}
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 (vis[0][c] == 0 && js)
{
ot[mz[js].front()] = c;
mz[js].pop();
chk[c] = 1;
}
for (int i = 0; i < 52; i++)
if (ot.count(getchr(i)))
{
cout << ot[getchr(i)];
}
cout << endl;
}
signed main()
{
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3592kb
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: 3812kb
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: 9ms
memory: 3612kb
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 cdbe abcdef afcgb fhebgd bhdcia jhcgfideba fkagcih klhgjbaedcif imfedhba nmagbdcek amnghdceo nofmlkjchdbegipa apoihfqdkme iqmonhckfrpgjedlba prsqgfencla trkmifgeqsbn utsghjfecdbq qotsrvjunmlkpiegfhdcba pwhvjgfedbca xvtsqnmkjfgwhicda ywlkjtogfexnba wzqjmnihafedcbg Azxibyhgfedcka BAzcxwqutsrv...
result:
wrong answer invalid length at case #3