QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#591321#7882. Linguistics PuzzlelimpidWA 3ms3864kbC++142.7kb2024-09-26 15:22:222024-09-26 15:22:22

Judging History

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

  • [2024-09-26 15:22:22]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3864kb
  • [2024-09-26 15:22:22]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
inline int read(){
    int f=1,ans=0; char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
    return f*ans;
}
const int MAXN = 65;
int cas, A[MAXN][MAXN];
int Q(char c){
	if(c >= 'a' && c <= 'z') return c - 'a';
	return 26 + c - 'A';
}
char Q_(int x){
	if(x <= 25) return 'a' + x;
	return (x - 26) + 'A';
}
int buc[MAXN][MAXN]; bool vis[MAXN]; int Ans[MAXN], N, GGG[MAXN];
vector<int> vec[MAXN], g, vec1[MAXN];
char str[5];
char Ans_i[MAXN];
void Print(vector<int> t){
	for(auto w: t) printf("%d ", w); printf("\n");
	return;
}
int main(){
	//freopen("1.in", "r", stdin);
	cas = read();
	while(cas--){
		N = read(); for(int i = 0; i < N; i++) vec[i].clear(), vec1[i].clear();
		memset(A, 0, sizeof(A)); memset(buc, 0, sizeof(buc)); memset(GGG, 0, sizeof(GGG));
		memset(vis, 0, sizeof(vis));
		memset(Ans, -1, sizeof(Ans));
		for(int i = 1; i <= N * N; i++){
			scanf("%s", str + 1); int len = strlen(str + 1);
			if(len == 1) GGG[Q(str[1])]++;
			else buc[Q(str[1])][Q(str[2])]++;
		}
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				int w = i * j;
				A[w / N][w % N]++;
			}
		}
		vec[0].pb(2 * N - 1);
		for(int i = 1; i < N; i++){
			g.clear();
			for(int j = 0; j < N; j++) if(A[i][j]) g.pb(A[i][j]);
			sort(g.begin(), g.end());
			vec[i] = g;
			vec[i].pb(A[0][i]);
		}
		for(int i = 0; i < N; i++){
			g.clear();
			for(int j = 0; j < N; j++) if(buc[i][j]){
				g.pb(buc[i][j]);
			}
			sort(g.begin(), g.end());
			vec1[i] = g; vec1[i].pb(GGG[i]);
		}
		for(int i = 0; i < N; i++){
			if(GGG[i] == 2 * N - 1){
				Ans[i] = 0; vis[0] = 1; continue;
			}
			for(int j = 1; j < N; j++){
				if(vis[j]) continue;
				if(vec1[i].size() != vec[j].size()) continue;
				bool flag = 1;
				for(int k = 0; k < vec1[i].size(); k++) flag &= (vec1[i][k] == vec[j][k]);
				if(flag){
					Ans[i] = j; vis[j] = 1; break;
				}
			}
		}
		int px = -1, py = -1;
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				if(i == j) continue;
				if(vec[i].size() != vec[j].size()) continue; bool flag = 1;
				for(int t = 0; t < vec[i].size(); t++) flag &= (vec[i][t] == vec[j][t]);
				if(flag){
					px = i, py = j;
					break;
				}
			}
		}
		//for(int i = 0; i < N; i++) cerr << Ans[i] << " "; cerr << endl;;
		for(int i = 0; i < N; i++) Ans_i[Ans[i]] = Q_(i);
		for(int i = 0; i < N; i++) cout << Ans_i[i]; cout << endl;

	}
}/*
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
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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: 3ms
memory: 3812kb

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
fcehabgd
bhgfedcia
jhcgfideba
fjbadkegcih
klhgjbaedcif
igkjmclfedhba
nflijahgmbdcek
anmlfijbgkhdceo
nofmlkjchdbegipa
aponblgjihcfqdkme
iqmonhckfrpgjedlba
prisodmbkjqghfencla
tcrdpoaklmjihfgeqsbn
utiraponmlksghjfecdbq
qotsrvjunmlkpiegfhdcba
pvutsrhwoimlkjnqgfedbca
xbvuts...

result:

wrong answer The product 2*5=10 is not in the output at case #6