QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#755497#7882. Linguistics Puzzletkt0506WA 2ms3640kbC++141.7kb2024-11-16 17:30:132024-11-16 17:30:13

Judging History

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

  • [2024-11-16 17:30:13]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3640kb
  • [2024-11-16 17:30:13]
  • 提交

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;
}

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

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']++;
            }
        }
    }

    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);

    // for(int i=1; i<=52; i++)cout << i << ":" << solve2(i) << "\n";



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

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

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: 2ms
memory: 3640kb

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