結果

問題 No.653 E869120 and Lucky Numbers
ユーザー pinpin
提出日時 2018-02-24 13:14:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,452 bytes
コンパイル時間 858 ms
コンパイル使用メモリ 84,448 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-21 09:05:24
合計ジャッジ時間 2,339 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 3 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 WA -
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 3 ms
6,944 KB
testcase_29 AC 3 ms
6,940 KB
testcase_30 AC 3 ms
6,940 KB
testcase_31 AC 2 ms
6,940 KB
testcase_32 AC 2 ms
6,948 KB
testcase_33 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:70:5: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   70 |     if (ans) cout << "Yes" << endl;
      |     ^~

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };

const ll MOD = 1000000007;
const ll INF = 100000;


string s;
bool judge(){
    int cnt = 0, cnt2 = 0;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == '9') return false;
        if (s[i] == '8') cnt++;
        if (s[i] == '1') cnt2++;
    }
    if (cnt > 1 || cnt2 > 1) return false;
    return true;
}
bool judge2(int L){
    for (int i = L; i < s.size(); i++){
        int d = s[i] - '0';
        if (i == s.size() - 1){
            if (d < 2 || 4 < d) return false;
        }
        else{
            if (d < 3 || 5 < d) return false;
        }
    }
    return true;
}
int main(void){
    cin >> s;
    if (!judge()){
        cout << "No" << endl;
        return 0;
    }

    bool ans;
    if (s[0] == '1'){
        if(s.size() == 1) ans = false;
        else ans = judge2(1);
    }
    else{
        for (int i = 0; i < s.size(); i++){
            int d = s[i] - '0';
            if (d < 6){
                if (s[i - 1] == '6') ans = false;
                else ans = judge2(i);
                break;
            }
        }
    }
    
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    
   
}
0