QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#271725#7882. Linguistics Puzzleucup-team045#WA 8ms3708kbC++201.8kb2023-12-02 14:17:012023-12-02 14:17:01

Judging History

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

  • [2023-12-02 14:17:01]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3708kb
  • [2023-12-02 14:17:01]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<map>
using namespace std;
using LL = long long;

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    auto get = [&](char c){
        if (islower(c)) return c - 'a';
        return 26 + c - 'A';
    };

    int T;
    cin >> T;
    while(T--){
        int n;
        cin >> n;
        vector<vector<pair<int, int> > > pos(n);
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                int x = i * j;
                vector<int> v;
                while(x){
                    v.push_back(x % n);
                    x /= n;
                }
                if (v.empty()) v.push_back(0);
                reverse(v.begin(), v.end());
                for(int k = 0; k < v.size(); k++){
                    pos[v[k]].push_back({v.size(), k});
                }
            }
        }
        map<vector<pair<int, int> >, vector<int> > mp;
        for(int i = 0; i < n; i++){
            sort(pos[i].begin(), pos[i].end());
            mp[pos[i]].push_back(i);
        }
        vector<vector<pair<int, int> > > cur(n);
        for(int i = 0; i < n * n; i++){
            string s;
            cin >> s;
            for(int j = 0; j < s.size(); j++){
                cur[get(s[j])].push_back({s.size(), j});
            }
        }
        string ans(n, '.');
        for(int i = 0; i < n; i++){
            sort(cur[i].begin(), cur[i].end());
            auto &v = mp[cur[i]];
            ans[v.back()] = i < 26 ? char('a' + i) : char('A' + i - 26);
            v.pop_back();
        }
        cout << ans << '\n';
    }

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3532kb

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

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: 0
Accepted
time: 8ms
memory: 3672kb

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:

ok OK

Test #4:

score: -100
Wrong Answer
time: 8ms
memory: 3708kb

input:

50
3
a a b c c c c bb c
4
a c ab b c ba ba c c a bc c c c d d
5
a a a b b b b b b c b d c b cc cc b d de e ea ed ed ee ee
6
a a ac ac b b b be ef c ca cb ea f cf d d e ca eb eb ec f ef c f f f f f f f f f cf ec
7
ag a a a ag b bb bb bd bd bf bf bf e bg c c c c c c c c c c c e c ga d da dd dd bf e e ...

output:

cba
cbad
becda
fecabd
cbgdafe
abgfechd
abhgeicdf
ahfdgcebij
bagedfcihjk
abcdhkgifjle
fkgdeachblijm
alcdbfgjihkmen
jfobedghiaklmcn
ahgdemcnijklfbop
aecdjlbhiqkfmnopg
aecdbfjhkimlgnopqr
afcdqbghriklmnopejs
dbcaefghijktmnosqrpl
qbisefgpcjklmnohdratu
pdcbeaghijmlknofqrstuv
aoedqfghijkclnbpmrstuvw
atcdef...

result:

wrong answer The product 4*37=148 is not in the output at case #43