結果
問題 |
No.791 うし数列
|
ユーザー |
![]() |
提出日時 | 2019-07-17 23:00:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 363 bytes |
コンパイル時間 | 594 ms |
コンパイル使用メモリ | 70,740 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 13:13:14 |
合計ジャッジ時間 | 1,338 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 |
ソースコード
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { string S; cin >> S; bool ok = S[0] == '1'; int n = S.length(); int cnt3 = count(S.begin() + 1, S.end(), '3'); ok &= cnt3 == n - 1 && cnt3 > 0; if (ok) { cout << cnt3 << endl; } else { cout << -1 << endl; } return 0; }