QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#755432#7882. Linguistics Puzzletkt0506WA 0ms3616kbC++141.9kb2024-11-16 17:19:572024-11-16 17:19:58

Judging History

This is the latest submission verdict.

  • [2024-11-16 17:19:58]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3616kb
  • [2024-11-16 17:19:57]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

vector<int>req(int n, int t){
    vector<int>cnt1(n,0), cnt2(n,0), cx(n,0);
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i*j < n)cnt1[i*j]++;
            else{
                cnt2[(i*j)%n]++;
                cx[(i*j)/n]++;
            }
        }
    }
    if(t == 1)return cnt1;
    else if(t == 2)return cnt2;
    else return cx;
}

void solve2(int n){
    // vector<int>r1 = req(n,1), r2 = req(n,2), r3 = req(n,3);
    // for(int i=0; i<n; i++){
    //     for(int j=0; j<n; j++){
    //         if(i == j)continue;
    //         if(r1[i] == r1[j] && r2[i] == r2[j] && r3[i] == r3[j]){
    //             cout << i << " " << j << "NOOOOO\n";
    //             return ;
    //         }
    //     }
    // }
}

void solve(){
    int n;
    cin >> n;

    vector<int>c1(n,0), c2(n,0), c3(n,0);
    vector<int>r1 = req(n,1), r2 = req(n,2), r3 = req(n,3);

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            string s;
            cin >> s;
            if(s.length() == 1){
                c1[s[0]-'a']++;
            }else{
                c2[s[1]-'a']++;
                c3[s[0]-'a']++;
            }
        }
    }

    // for(int i=0; i<n; i++)cout << c1[i] << " " << c2[i] << " " << c3[i] << "\n";
    // cout << "\n";
    // for(int i=0; i<n; i++)cout << r1[i] << " " << r2[i] << " " << r3[i] << "\n";

    vector<int>ans(n,-1);
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(ans[j] != -1)continue;
            if(c1[i] == r1[j] && c2[i] == r2[j] && c3[i] == r3[j]){
                ans[j] = i;
                break;
            }
        }
    }

    for(int e : ans)cout << (char)(e+'a');
    cout << "\n";
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int t;
    cin >> t;
    while(t--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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 invalid character ` at case #25