結果

問題 No.653 E869120 and Lucky Numbers
ユーザー pinpin
提出日時 2018-02-24 13:39:43
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,666 bytes
コンパイル時間 671 ms
コンパイル使用メモリ 82,680 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 12:31:52
合計ジャッジ時間 1,717 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 3 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:79:5: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   79 |     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;
int cnt;
bool judge(){
    int cnt2 = 0;
    for (int i = 0; i < s.size(); i++){
        int d = s[i] - '0';
        if (i == 0){
            if (d != 1 && d != 6 && d != 7) return false;
        }
        if (i == s.size() - 1){
            if (d < 2 || 4 < d) return false;
        }
        if (d == 9) return false;
        if (d == 8) cnt++;
        if (d == 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' || (s[i - 1] == '7' && cnt == 1)) ans = false;
                else ans = judge2(i);
                break;
            }
        }
    }

    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;



}
0