結果

問題 No.791 うし数列
ユーザー momoyuu
提出日時 2024-09-30 02:03:33
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 1,008 ms
コンパイル使用メモリ 92,416 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-09-30 02:03:36
合計ジャッジ時間 1,419 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string s;
    cin>>s;
    bool fn = true;
    int n = s.size();
    for(int i = 0;i<n;i++){
        if(i==0){
            if(s[i]!='1') fn = false;
        }else{
            if(s[i]!='3') fn = false;
        }
    }
    if(fn){
        int m = s.size();
        if(m==1) cout<<-1<<endl;
        else cout<<m-1<<endl;
    }else{
        cout<<-1<<endl;
    }
}   

0