結果

問題 No.355 数当てゲーム(2)
ユーザー sugarrrsugarrr
提出日時 2018-07-23 01:23:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 2,383 bytes
コンパイル時間 815 ms
コンパイル使用メモリ 89,196 KB
実行使用メモリ 24,384 KB
平均クエリ数 5.52
最終ジャッジ日時 2023-09-24 01:51:35
合計ジャッジ時間 5,403 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
24,240 KB
testcase_01 AC 26 ms
23,364 KB
testcase_02 AC 25 ms
23,520 KB
testcase_03 AC 26 ms
24,204 KB
testcase_04 AC 25 ms
23,808 KB
testcase_05 AC 25 ms
24,012 KB
testcase_06 AC 26 ms
23,784 KB
testcase_07 AC 26 ms
23,436 KB
testcase_08 AC 26 ms
24,012 KB
testcase_09 AC 26 ms
23,604 KB
testcase_10 AC 26 ms
24,012 KB
testcase_11 AC 26 ms
24,204 KB
testcase_12 AC 25 ms
23,640 KB
testcase_13 AC 27 ms
23,376 KB
testcase_14 AC 26 ms
24,060 KB
testcase_15 AC 27 ms
24,012 KB
testcase_16 AC 25 ms
23,412 KB
testcase_17 AC 25 ms
24,036 KB
testcase_18 AC 25 ms
23,832 KB
testcase_19 AC 26 ms
23,604 KB
testcase_20 AC 26 ms
23,412 KB
testcase_21 AC 26 ms
23,568 KB
testcase_22 AC 25 ms
24,312 KB
testcase_23 AC 25 ms
24,084 KB
testcase_24 AC 27 ms
23,400 KB
testcase_25 AC 25 ms
23,520 KB
testcase_26 AC 25 ms
23,616 KB
testcase_27 AC 25 ms
23,640 KB
testcase_28 AC 26 ms
24,204 KB
testcase_29 AC 25 ms
23,388 KB
testcase_30 AC 25 ms
24,012 KB
testcase_31 AC 25 ms
23,436 KB
testcase_32 AC 29 ms
23,412 KB
testcase_33 AC 26 ms
24,192 KB
testcase_34 AC 27 ms
23,520 KB
testcase_35 AC 24 ms
24,012 KB
testcase_36 AC 25 ms
23,340 KB
testcase_37 AC 25 ms
24,384 KB
testcase_38 AC 26 ms
24,204 KB
testcase_39 AC 25 ms
23,640 KB
testcase_40 AC 25 ms
23,640 KB
testcase_41 AC 26 ms
23,856 KB
testcase_42 AC 24 ms
23,988 KB
testcase_43 AC 25 ms
23,436 KB
testcase_44 AC 25 ms
24,252 KB
testcase_45 AC 25 ms
24,276 KB
testcase_46 AC 24 ms
24,048 KB
testcase_47 AC 24 ms
23,520 KB
testcase_48 AC 26 ms
24,276 KB
testcase_49 AC 26 ms
23,676 KB
testcase_50 AC 26 ms
23,424 KB
testcase_51 AC 25 ms
24,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


//////////////////////////////////////
#define koko 0

void print(int a,int b,int c,int d){
    cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
    fflush(stdout);
}

int main(){
    int q[100][6];
    rep(i,0,koko-1){
        int a[4];
        bool flag=true;
        while(flag){
            rep(j,0,3){
                a[j]=(int)rand()%10;
            }
            set<int>s;
            rep(j,0,3)s.insert(a[j]);
            if(s.size()==4){
                flag=false;
            }
        }
        rep(j,0,3)q[i][j]=a[j];
        print(a[0],a[1],a[2],a[3]);
        cin>>q[i][4]>>q[i][5];
        if(q[i][4]==4&&q[i][5]==0){
            return 0;
        }

    }
    int pos=koko;
    rep(i,0,9999){
        int b[4];
        int c=i;
        rep(j,0,3){
            b[3-j]=c%10;
            c/=10;
        }
        set<int>s;
        rep(j,0,3)s.insert(b[j]);
        if(s.size()==4){
            bool flag=true;
            rep(j,0,pos-1){
                int coua=0;
                rep(k,0,3){
                    if(b[k]==q[j][k])coua++;
                }
                if(coua!=q[j][4]){
                    flag=false;break;
                }
                int coub=-coua;
                rep(k,0,3){
                    rep(l,0,3){
                        if(b[k]==q[j][l])coub++;
                    }
                }
                if(coub!=q[j][5]){
                    flag=false;break;
                }
            }
            if(flag){
                rep(j,0,3)q[pos][j]=b[j];
                print(b[0],b[1],b[2],b[3]);
                cin>>q[pos][4]>>q[pos][5];
                if(q[pos][4]==4&&q[pos][5]==0){
                    return 0;
                }
                pos++;
            }
        }
    }
    
    
    return 0;
}
0