結果

問題 No.2745 String Swap Battle
ユーザー tailstails
提出日時 2024-04-21 01:35:57
言語 cLay
(20240104-1)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 644 bytes
コンパイル時間 2,652 ms
コンパイル使用メモリ 175,884 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2024-04-21 01:36:01
合計ジャッジ時間 3,524 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 4 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 9 ms
7,424 KB
testcase_13 AC 9 ms
7,424 KB
testcase_14 AC 9 ms
7,296 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

ll@n;
string@ss[n];
rep(i,n){
	string&s=ss[i];
	char b='~';
	char w=0;
	int o=0;
	int bj=-1;
	int c;
	int j;
	for(j=0;c=s[j];++j){
		if(c==w){
			o=1;
		}
		if(c>w){
			w=c;
		}
		if(c<w&&c<=b){
			b=c;
			bj=j;
		}
	}
	if(bj>=0){
		for(int j=0;c=s[j];++j){
			if(c>b){
				swap(s[j],s[bj]);
				break;
			}
		}
	}
	else if(!o){
		swap(s[j-1],s[j-2]);
	}
}
int q[n];
int qn=n;
rep(i,n){
	q[i]=i;
}
for(int j=0;;++j){
	int b='~';
	rep(i,qn){
		b<?=ss[q[i]][j];
	}
	int w=0;
	rep(i,qn){
		if(ss[q[i]][j]==b){
			q[w++]=q[i];
		}
	}
	qn=w;
	if(!b){
		break;
	}
}
int r=0;
rep(i,n){
	if(r<qn&&q[r]==i){
		++r;
		wt(n+1-qn);
	}else{
		wt('0');
	}
}
0