結果
| 問題 | 
                            No.653 E869120 and Lucky Numbers
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ts_
                         | 
                    
| 提出日時 | 2018-04-06 23:11:26 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 951 bytes | 
| コンパイル時間 | 1,281 ms | 
| コンパイル使用メモリ | 160,916 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-13 18:18:58 | 
| 合計ジャッジ時間 | 2,258 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 31 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;
int main(){
    string s;
    cin>>s;
    int cur=0;
    int n=s.size();
    bool flag=false;
    for(int i=n-1;i>=0;--i){
        if(cur==0){
            if(i!=n-1&&(s[i]=='7'||s[i]=='6')) flag=true;
            else if(!flag&&(s[i]=='2'||s[i]=='3'||s[i]=='4')) cur=1;
            else{
                cout<<"No"<<endl;
                return 0;
            }
        }
        else if(cur==1){
            if(s[i]=='7'||s[i]=='8') flag=true,cur=0;
            else if(!flag&&(s[i]=='3'||s[i]=='4'||s[i]=='5')) cur=1;
            else if(!flag&&i==0&&s[i]=='1') cur=0; 
            else{
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    if(cur==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}
            
            
            
        
            
ts_