結果

問題 No.632 穴埋め門松列
ユーザー ganariya
提出日時 2018-01-19 21:39:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,175 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 76,460 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 12:28:30
合計ジャッジ時間 1,033 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:60:16: warning: 'index1' may be used uninitialized [-Wmaybe-uninitialized]
   60 |     if(checkMax(array,index4)){
      |        ~~~~~~~~^~~~~~~~~~~~~~
main.cpp:37:9: note: 'index1' was declared here
   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