結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
not_522
|
| 提出日時 | 2016-06-20 01:41:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 580 bytes |
| コンパイル時間 | 1,576 ms |
| コンパイル使用メモリ | 167,352 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-25 11:48:27 |
| 合計ジャッジ時間 | 2,331 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
struct Initializer {
Initializer() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(15);
}
} initializer;
int main() {
string s;
cin >> s;
int a = -1, b = -1, res = numeric_limits<int>::max();
for (int i = 0; i < (int)s.size(); ++i) {
if (s[i] == 'c') {
a = i;
} else if (s[i] == 'w') {
if (b != -1) {
res = min(res, i - b + 1);
}
if (a != -1) {
b = a;
}
}
}
cout << (res != numeric_limits<int>::max() ? res : -1) << endl;
}
not_522