結果
| 問題 | No.653 E869120 and Lucky Numbers | 
| コンテスト | |
| ユーザー |  pin | 
| 提出日時 | 2018-02-24 13:39:43 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 1,666 bytes | 
| コンパイル時間 | 2,878 ms | 
| コンパイル使用メモリ | 82,196 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-06 20:25:16 | 
| 合計ジャッジ時間 | 1,935 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 30 WA * 1 | 
コンパイルメッセージ
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;
      |     ^~
            
            ソースコード
#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;
}
            
            
            
        