結果

問題 No.632 穴埋め門松列
ユーザー ganariyaganariya
提出日時 2018-01-19 21:39:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 1,175 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 76,112 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 00:13:25
合計ジャッジ時間 1,131 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:60:16: 警告: ‘index1’ may be used uninitialized [-Wmaybe-uninitialized]
   60 |     if(checkMax(array,index4)){
      |        ~~~~~~~~^~~~~~~~~~~~~~
main.cpp:37:9: 備考: ‘index1’ はここで定義されています
   37 |     int index1;
      |         ^~~~~~

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <map>

using namespace std;

bool checkMax(int *array,int index){
    bool isOk=false;
    int maxIndex=0,minIndex=0;
    for(int i=0;i<3;i++){
        if(array[i]<array[maxIndex]){
            maxIndex=i;
        }
        if(array[i]>array[minIndex]){
            minIndex=i;
        }
    }
    if(1==maxIndex||1==minIndex){
        isOk=true;
    }
    return isOk;
}

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

    int array[4];
    int array1[4];
    int array4[4];
    string ch;
    int index1;
    int index4;

    for(int i=0;i<3;i++){
        cin>>ch;
        if(ch[0]=='?'){
            array[i]=-1;
            array1[i]=-1;
            array4[i]=-1;
            index1=i;
            index4=i;
        }else{
            array[i]=ch[0]-'0';
            array1[i]=ch[0]-'0';
            array4[i]=ch[0]-'0';
        }
    }

    array[index1]=1;
    if(checkMax(array,index1)){
        printf("1");
    }
    array[index4]=4;
    if(checkMax(array,index4)){
        printf("4");
    }

    return 0;
}
0