結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
Lavender
|
| 提出日時 | 2019-09-04 16:21:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 531 bytes |
| コンパイル時間 | 2,298 ms |
| コンパイル使用メモリ | 165,832 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 17:27:46 |
| 合計ジャッジ時間 | 3,492 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:6:13: warning: 'c' may be used uninitialized [-Wmaybe-uninitialized]
6 | int t,w,c,m,flug=0;
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
int t,w,c,m,flug=0;
cin>>s;
m=s.length();
for(int i=0;i<s.length();i++){
if(s[i]=='c'){
w=0;
for(int t=i;t<s.length();t++){
if(s[t]=='w')w++;
if(w==2){
c=t-i;
flug=1;
break;
}
}
if(m>c)m=c;
}
}
if(flug==0)cout<<-1<<endl;
else cout<<m+1<<endl;
return 0;
}
Lavender