QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#646009#7882. Linguistics Puzzlebessie_goes_mooWA 13ms6704kbC++142.6kb2024-10-16 20:52:322024-10-16 20:52:33

Judging History

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

  • [2024-10-16 20:52:33]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:6704kb
  • [2024-10-16 20:52:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5;
int T, n, maxx;
int num1[101], num2[101], dui[N], tong[101][101];
inline int read() {
	int al = 0, fh = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-')
			fh = -1;
		ch = getchar();
	}
	while (ch <= '9' && ch >= '0') {
		al = al * 10 + ch - '0';
		ch = getchar();
	}
	return al * fh;
}
char str[101];
vector<int> x[N];
void clear() {
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			tong[i][j] = 1;
		}
	}
}
int chu(int a) {
	if (a <= 'z' && a >= 'a') {
		return a - 'a';
	}
	else {
		return a - 'A' + 26;
	}
}
int con_x[101], con_y[101], vis[101];
bool dfs(int x) {
	for (int y = 0; y < n; y++)
		if (tong[x][y] && !vis[y]) {
			vis[y] = true;
			if (con_y[y] == -1 || dfs(con_y[y])) {
				con_x[x] = y;
				con_y[y] = x;
				return true;
			}
		}
	return false;
}

void Maxmatch() {
	for (int i = 0; i <= n; i++) {
		con_y[i] = con_x[i] = -1;
	}
	for (int i = 0; i < n; i++)
	{
		 {
			memset(vis, false, sizeof(vis));
			dfs(i);
		}
	}
}
char zhuan(int x) {
	if (x <= 25)
		return x + 'a';
	else return x + 'A' - 26;
}
signed main() {
	//freopen("out.txt","r",stdin);
	T = read();
	for (int yyc = 1; yyc <= T; yyc++) {
		n = read();
		clear();
		int maxx=101;
		for (int i = 1; i <= n * n; i++) {
			scanf("%s", str);
			int l = strlen(str);
			maxx = max(maxx, l);
			x[i].resize(l);
			for (int j = 0; j < l; j++) {
				x[i][j] = chu(str[l - 1 - j]);
			}
		}
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				dui[++cnt] = i * j;
			}
		}
		for (int i = 0; i < maxx; i++) {
			for (int j = 0; j <= n; j++) {
				num1[j] = 0;
				num2[j] = 0;
			}
			for (int j = 1; j <= n * n; j++) {
				if (x[j].size() >= i + 1) {
					num2[x[j][i]]++;
				}
			}
			for (int j = 1; j <= cnt; j++) {
				if (dui[j] != -1) {
					num1[dui[j] % n]++;
					if(dui[j]/n==0)
						dui[j]=-1;
					else dui[j] /= n;
				}
			}
			// cout<<i<<":";
			// for(int j=0;j<n;j++){
			// 	cout<<num1[j]<<" "<<num2[j]<<endl;
			// }
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < n; k++) {
					if (num1[j] == num2[k]) {
					}
					else {
						tong[j][k] = 0;
					}
				}
			}
		}
		// for(int i=0;i<n;i++){
		// 	for(int j=0;j<n;j++){
		// 		cout<<tong[i][j]<<" ";
		// 	}
		// 	cout<<endl;
		// }
		Maxmatch();
		for (int i = 0; i < n; i++) {
			if(chu(zhuan(con_x[i]))<0||chu(zhuan(con_x[i]))>51){
				while(1){

				}
			}
			cout << zhuan(con_x[i]);
		}
		cout << endl;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 6704kb

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: 1ms
memory: 6104kb

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: 13ms
memory: 6128kb

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
pvutsrhwoimlnjkqgfedbca
xbvuts...

result:

wrong answer The product 3*20=60 is not in the output at case #21