結果
問題 | No.1694 ZerOne |
ユーザー |
|
提出日時 | 2021-10-02 00:16:07 |
言語 | D (dmd 2.109.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 702 bytes |
コンパイル時間 | 1,609 ms |
コンパイル使用メモリ | 171,544 KB |
実行使用メモリ | 13,880 KB |
最終ジャッジ日時 | 2024-06-22 12:41:05 |
合計ジャッジ時間 | 4,903 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | TLE * 1 -- * 30 |
ソースコード
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); }