結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2020-05-03 12:53:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 605 bytes |
コンパイル時間 | 1,328 ms |
コンパイル使用メモリ | 167,876 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-11 19:50:07 |
合計ジャッジ時間 | 2,124 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int c = 0, n = 0; for (int i = 0; i < s.size(); i++) { if (!c) { if (s.at(i) == 'c') { c = 1; n = i; } else { continue; } } else if (c == 1) { if (s.at(i) == 'w') { c = 2; } else { continue; } } else if (c == 2) { if (s.at(i) == 'w') { c = 3; n -= i; n = abs(n); n++; break; } else { continue; } } else { cout << "WA" << endl; return 0; } } if (c == 3) { cout << n << endl; } else { cout << -1 << endl; } }