結果
| 問題 | No.345 最小チワワ問題 |
| コンテスト | |
| ユーザー |
sorag
|
| 提出日時 | 2022-08-08 09:31:22 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 674 bytes |
| 記録 | |
| コンパイル時間 | 1,790 ms |
| コンパイル使用メモリ | 168,580 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-06 21:04:21 |
| 合計ジャッジ時間 | 3,959 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#define all(x) x.begin(),x.end()
#define pb push_back
#define ll long long
#define P pair<int,int>
#define LP pair<ll,ll>
using namespace std;
int main() {
string s;
cin >> s;
int len;
int ans = numeric_limits<int>::max();
bool f = 0;
for (int i = 0; i <s.size(); i++) {
for (int j = i + 1; j < s.size(); j++) {
for (int k = j + 1; k < s.size(); k++) {
if (s[i] == 'c' and s[j] == 'w' and s[k] == 'w') {
len = k - i + 1;
ans = min(ans, len);
}
}
}
}
if (ans == numeric_limits<int>::max()) ans = -1;
cout << ans<< endl;
return 0;
}
sorag