結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
kekenx
|
| 提出日時 | 2020-03-05 13:10:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 578 bytes |
| コンパイル時間 | 1,654 ms |
| コンパイル使用メモリ | 169,288 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-14 01:00:27 |
| 合計ジャッジ時間 | 2,526 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int INF = 10000000;
typedef long long ll;
int main() {
string s;
cin >> s;
vector<int> c;
vector<int> w;
for (int i = 0; i < s.size(); ++i) {
if (s[i] == 'c') c.push_back(i);
if (s[i] == 'w') w.push_back(i);
}
int ans = INF;
for (int i = 0; i < c.size(); ++i) {
int cnt = 0;
for (int j = 0; j < w.size(); ++j) {
if (w[j] > c[i]) {
cnt++;
if (cnt == 2) {
ans = min(ans, w[j] - c[i] + 1);
}
}
}
}
if (ans == INF) puts("-1");
else cout << ans << '\n';
return 0;
}
kekenx