結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
ui_mtc
|
| 提出日時 | 2020-03-14 19:58:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 617 bytes |
| コンパイル時間 | 1,730 ms |
| コンパイル使用メモリ | 166,172 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-23 21:27:19 |
| 合計ジャッジ時間 | 2,608 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 4 |
ソースコード
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
string S;
cin >> S;
bool fg1 = false;
bool fg2 = false;
int cnt = 0;
int ans = 10000000;
for( int i = 0; i < S.size(); i++ ){
cnt++;
if( S.at(i) == 'c' ){
if( fg2 == false ){
fg1 = true;
cnt = 1;
}
}else if( S.at(i) == 'w' ){
if( fg2 ){
ans = min(ans, cnt);
fg1 = false;
fg2 = false;
}else if( fg1 == true && fg2 == false ){
fg2 = true;
}
}
}
if( ans != 10000000 ) cout << ans << endl;
else cout << -1 << endl;
}
ui_mtc