結果

問題 No.1694 ZerOne
ユーザー laneguelanegue
提出日時 2021-10-02 00:16:07
言語 D
(dmd 2.106.1)
結果
TLE  
実行時間 -
コード長 702 bytes
コンパイル時間 1,964 ms
コンパイル使用メモリ 159,524 KB
実行使用メモリ 344,812 KB
最終ジャッジ日時 2023-09-04 14:20:06
合計ジャッジ時間 6,394 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,508 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;
void main(){
	auto S=readln.chomp;
	auto L=S.length;
	auto q=DList!(string)([S]);
	bool[string] used;
	used[S]=true;
	auto result=1;
	while(!q.empty){
		auto s=q.front;
		q.removeFront;
		//stderr.writeln(s);
		int[] zo;
		int[] oz;
		for(auto i=0;i<L-1;i++){
			if(s[i]=='0'&&s[i+1]=='1'){
				zo~=i;
			}
			if(s[i]=='1'&&s[i+1]=='0'){
				oz~=i;
			}
		}
		//stderr.writeln(zo);
		//stderr.writeln(oz);
		foreach(i;zo){
			foreach(j;oz){
				if((i-j).abs==1)continue;
				char[] c=s.dup;
				c[i]='1';
				c[i+1]='0';
				c[j]='0';
				c[j+1]='1';
				string cs=c.idup;
				if(cs in used)continue;
				q.insert(cs);
				used[cs.idup]=true;
				result++;
			}
		}
	}
	writeln(result);
}

0