QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#273564 | #7882. Linguistics Puzzle | ucup-team1134# | RE | 0ms | 3624kb | C++23 | 2.6kb | 2023-12-03 01:32:04 | 2023-12-03 01:32:06 |
Judging History
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;
}
*/
}
详细
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 ...