結果
| 問題 | No.791 うし数列 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-04-08 09:49:53 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 472 bytes | 
| コンパイル時間 | 593 ms | 
| コンパイル使用メモリ | 67,364 KB | 
| 最終ジャッジ日時 | 2025-01-09 15:05:24 | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 15 | 
ソースコード
#include <iostream>
#include <string>
void solve() {
    std::string s;
    std::cin >> s;
    int ans = s.length() - 1;
    bool ok = ans > 0;
    for (int i = 0; i < (int)s.length(); ++i) {
        if ((i == 0 && s[i] != '1') ||
            (i > 0 && s[i] != '3')) {
            ok = false;
        }
    }
    std::cout << (ok ? ans : -1) << std::endl;
}
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    solve();
    return 0;
}
            
            
            
        