結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
kkkk97368086
|
| 提出日時 | 2021-12-01 12:28:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 399 bytes |
| コンパイル時間 | 1,588 ms |
| コンパイル使用メモリ | 167,932 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 11:58:19 |
| 合計ジャッジ時間 | 2,544 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
string s; cin >> s;
int ans = 101101;
int n = s.size();
int w1 = n, w2 = n;
for (int i = n - 1; i >= 0; i--) {
if (s[i] == 'w') {
w1 = w2;
w2 = i;
}
if (s[i] == 'c' && w1 != n) {
ans = min(ans, w1 - i + 1);
}
}
if (ans == 101101) cout << -1 << endl;
else cout << ans << endl;
return 0;
}
kkkk97368086