QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#270235#7882. Linguistics Puzzleucup-team206#WA 4ms3492kbC++171.6kb2023-11-30 16:54:302023-11-30 16:54:31

Judging History

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

  • [2023-11-30 16:54:31]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3492kb
  • [2023-11-30 16:54:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int N = 55;
inline int ch2id(char c) {
    if (islower(c)) return c - 'a';
    return 26 + c - 'A';
}
inline char id2ch(int x) {
    if (x < 26) return 'a' + x;
    return 'A' + x - 26;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int Case;
    cin >> Case;
    while (Case--) {
        int n;
        cin >> n;
        vector<pii> cnt(n);
        vector<vector<int>> mp(n, vector<int>(n));
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j) {
                int val = i * j;
                cnt[val % n].first += 1;
                if (val >= n) {
                    mp[val / n][val % n] += 1;
                    cnt[val / n].second += 1;
                }
            }
        for (int i = 0; i < n; ++i) sort(mp[i].begin(), mp[i].end());
        vector<pii> cnt_real(n);
        vector<vector<int>> mp_real(n, vector<int>(n));
        for (int i = 0; i < n * n; ++i) {
            string s;
            cin >> s;
            cnt_real[ch2id(s.back())].first += 1;
            if (s.size() == 2) {
                mp_real[ch2id(s[0])][ch2id(s[1])] += 1;
                cnt_real[ch2id(s[0])].second += 1;
            }
        }
        for (int i = 0; i < n; ++i) sort(mp_real[i].begin(), mp_real[i].end());
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) if (cnt[i] == cnt_real[j] && mp[i] == mp_real[j]) {
                cout << id2ch(j);
                break;
            }
        }
        cout << endl;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3456kb

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: 1ms
memory: 3416kb

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: 4ms
memory: 3492kb

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
pvutsrhwoimlkjkqgfedbca
xbvuts...

result:

wrong answer invalid character k at case #21