QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#273564#7882. Linguistics Puzzleucup-team1134#RE 0ms3624kbC++232.6kb2023-12-03 01:32:042023-12-03 01:32:06

Judging History

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

  • [2023-12-03 01:32:06]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3624kb
  • [2023-12-03 01:32:04]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int Q;cin>>Q;
    while(Q--){
        int n;cin>>n;
        
        vector<int> ONE(n),A(n),B(n);
        for(int a=0;a<n;a++){
            for(int b=0;b<n;b++){
                int x=a*b;
                if(x<n) ONE[x]++;
                else{
                    A[x/n]++;
                    B[x%n]++;
                }
            }
        }
        
        map<tuple<int,int,int>,int> MA;
        for(int i=0;i<n;i++){
            MA[{ONE[i],A[i],B[i]}]=i;
        }
        
        for(int i=0;i<n;i++){
            ONE[i]=0;
            A[i]=0;
            B[i]=0;
        }
        for(int i=0;i<n*n;i++){
            string S;cin>>S;
            if(si(S)==1){
                int x;
                if(S[0]<='z') x=(int)(S[0]-'a');
                else x=(int)(S[0]-'A')+26;
                
                ONE[x]++;
            }else{
                int x,y;
                if(S[0]<='z') x=(int)(S[0]-'a');
                else x=(int)(S[0]-'A')+26;
                
                if(S[1]<='z') y=(int)(S[1]-'a');
                else y=(int)(S[1]-'A')+26;
                
                A[x]++;
                B[y]++;
            }
        }
        
        string ans(n,'.');
        
        for(int i=0;i<n;i++){
            int x=MA[{ONE[i],A[i],B[i]}];
            if(i<26) ans[x]=char('a'+i);
            else ans[x]=char('A'+(i-26));
        }
        cout<<ans<<"\n";
    }
    
    /*
    for(int n=2;n<=52;n++){
        vector<int> ONE(n),A(n),B(n);
        for(int a=0;a<n;a++){
            for(int b=0;b<n;b++){
                int x=a*b;
                if(x<n) ONE[x]++;
                else{
                    A[x/n]++;
                    B[x%n]++;
                }
            }
        }
        set<tuple<int,int,int>> SE;
        for(int i=0;i<n;i++){
            SE.insert({ONE[i],A[i],B[i]});
            //cout<<ONE[i]<<" "<<A[i]<<" "<<B[i]<<endl;
        }
        //cout<<endl;
        
        cout<<n<<" "<<si(SE)<<endl;
    }
     */
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
Runtime Error

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:


result: