結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2016-04-17 16:29:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 442 bytes |
コンパイル時間 | 1,399 ms |
コンパイル使用メモリ | 158,204 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-04 10:25:47 |
合計ジャッジ時間 | 1,940 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=a;i<b;i++) int main() { string s; cin >> s; int phase = 0; int ans; rep(i, 0, s.length()) { if (phase == 0 && s[i] == 'c') { phase++; ans = i; } else if (phase == 1 && s[i] == 'w') phase++; else if (phase == 2 && s[i] == 'w') { phase++; ans = i - ans + 1; } } if (phase == 3) cout << ans << endl; else cout << -1 << endl; }