結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2020-07-18 21:39:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 449 bytes |
| コンパイル時間 | 1,526 ms |
| コンパイル使用メモリ | 167,976 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-14 08:36:38 |
| 合計ジャッジ時間 | 2,672 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int INF = 100000;
int main(){
string S;
cin >> S;
int N = S.size();
int ans = INF;
for (int i = 0; i < N; i++){
for (int j = i + 1; j < N; j++){
for (int k = j + 1; k < N; k++){
if (S[i] == 'c' && S[j] == 'w' && S[k] == 'w'){
ans = min(ans, k - i + 1);
}
}
}
}
if (ans == INF){
cout << -1 << endl;
} else {
cout << ans << endl;
}
}
SSRS