結果
問題 | No.345 最小チワワ問題 |
ユーザー | rogi52 |
提出日時 | 2022-09-26 13:43:03 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 595 bytes |
コンパイル時間 | 2,181 ms |
コンパイル使用メモリ | 199,660 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-22 15:26:00 |
合計ジャッジ時間 | 3,418 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); string s; cin >> s; int ans = 1e9; rep(i,int(s.size())) { if(s[i] == 'c') { int cnt = 0; for(int j = i + 1; j < int(s.size()); j++) { if(s[j] == 'w') cnt++; if(cnt == 2) { ans = min(ans, j - i + 1); break; } } } } cout << (ans == int(1e9) ? -1 : ans) << endl; }