結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
![]() |
提出日時 | 2017-07-07 03:10:14 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 137 ms / 2,000 ms |
コード長 | 743 bytes |
コンパイル時間 | 313 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 12,388 KB |
最終ジャッジ日時 | 2024-10-06 04:19:39 |
合計ジャッジ時間 | 2,103 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
S=list(input())i=0Co=[]while i<len(S)-1:# print (S)if S[i]=="c":# print (i)while i<len(S):# print (i)cc=0while i<len(S) and S[i]!="w":if S[i]=="c":cc+=1i+=1Co.append(cc)cw=0while i<len(S) and S[i]!="c":if S[i]=="w":cw+=1i+=1Co.append(cw)i+=1i+=1#print (Co)Sc=0if len(Co)>1:St=len(Co)if len(Co)%2==1:St-=1else:St=0Nw=0if St>2 and Co[St-1]==1 :Nw+=1St-=2while St>1:Nw+=Co[St-1]Nw1=Nw-1Nw1*=NwNw1//=2Sc+=Nw1*Co[St-2]St-=2print (Sc)