結果
問題 | No.345 最小チワワ問題 |
ユーザー |
|
提出日時 | 2023-01-07 19:46:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 468 bytes |
コンパイル時間 | 1,592 ms |
コンパイル使用メモリ | 168,388 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-14 19:41:46 |
合計ジャッジ時間 | 2,628 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ string S; cin>>S; int size=S.size(); bool frag=false; int M=10000; for(int i=0;i<size-2;i++){ for(int j=i+1;j<size-1;j++){ for(int w=j+1;w<size;w++){ if(S[i]=='c' && S[j]=='w' && S[w]=='w'){ frag=true; M=min(M,w-i+1); } } } } if(frag){ cout<<M<<endl; } else{ cout<<-1<<endl; } }