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