結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
hachidesyu
|
| 提出日時 | 2020-07-06 17:56:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 982 bytes |
| コンパイル時間 | 1,557 ms |
| コンパイル使用メモリ | 167,428 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-24 17:16:29 |
| 合計ジャッジ時間 | 2,317 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin >> s;
int res = -1;
//一番右のcを探す
int last_c = s.size();
int loop = 0;
while(last_c != 0){
int count_w = 0;
for(int i = 0; i < last_c; i++){
if(s[i] == 'c'){
// if(!strcmp(c, "c")){
last_c = i;
}
}
//一番右のcからwが二つ目まで探す
for(int i = last_c; i < s.size(); i++){
if(s[i] == 'w'){
// if(!strcmp(c, "w")){
count_w++;
}
if(count_w == 2){
// cout << "i = " << i << endl;
// cout << "last_c = " << last_c << endl;
res = i-last_c+1;
// cout << "res = " << res << endl;
break;
}
}
if(res != -1) break;
loop++;
if(loop > 200) break;
}
cout << res << endl;
}
hachidesyu