QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#413637#7882. Linguistics Puzzlek1nsomWA 9ms3580kbC++172.8kb2024-05-17 20:18:392024-05-17 20:18:40

Judging History

你现在查看的是最新测评结果

  • [2024-05-17 20:18:40]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:3580kb
  • [2024-05-17 20:18:39]
  • 提交

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;
map<pair<PII, int>, queue<char>> 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();
    zzm.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[{{cnt[0][c], cnt[1][c]}, 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 (!chk[c] && js)
        {
            mz[js].push(c);
            chk[c] = 1;
        }
    chk.clear();
    for (auto [c, js] : vis[2])
        if (!chk[c] && js)
        {
            ot[zzm[{{vis[0][c], vis[1][c]}, js}].front()] = c;
            zzm[{{vis[0][c], vis[1][c]}, 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 (!chk[c] && 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: 3512kb

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: 3580kb

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: 3540kb

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
prisodmbkjqghfencla
tcrdpoaklmjihfgeqsbn
utiraponmlksghjfecdbq
qotsrvjunmlkpiegfhdcba
pvutsrhwoimlkjnqgfedbca
xbvuts...

result:

wrong answer The product 3*15=45 is not in the output at case #27