結果

問題 No.850 企業コンテスト2位
ユーザー ttttan2ttttan2
提出日時 2019-07-05 22:52:21
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,735 bytes
コンパイル時間 1,710 ms
コンパイル使用メモリ 148,872 KB
実行使用メモリ 24,252 KB
平均クエリ数 216.14
最終ジャッジ日時 2023-09-23 17:35:52
合計ジャッジ時間 4,679 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,508 KB
testcase_01 AC 23 ms
23,496 KB
testcase_02 AC 24 ms
23,892 KB
testcase_03 AC 24 ms
24,204 KB
testcase_04 AC 25 ms
23,496 KB
testcase_05 AC 23 ms
24,132 KB
testcase_06 AC 22 ms
23,652 KB
testcase_07 AC 27 ms
23,964 KB
testcase_08 AC 30 ms
23,400 KB
testcase_09 AC 29 ms
24,180 KB
testcase_10 WA -
testcase_11 AC 33 ms
24,180 KB
testcase_12 WA -
testcase_13 AC 33 ms
23,820 KB
testcase_14 AC 32 ms
23,880 KB
testcase_15 AC 32 ms
23,388 KB
testcase_16 AC 33 ms
23,388 KB
testcase_17 WA -
testcase_18 AC 33 ms
23,520 KB
testcase_19 AC 33 ms
24,204 KB
testcase_20 AC 31 ms
23,484 KB
testcase_21 WA -
testcase_22 AC 33 ms
24,252 KB
testcase_23 AC 33 ms
23,496 KB
testcase_24 AC 36 ms
23,904 KB
testcase_25 AC 33 ms
23,400 KB
testcase_26 WA -
testcase_27 AC 23 ms
23,880 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:81:17: warning: ‘num’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     cout<<"! "<<num<<endl;
                 ^~~

ソースコード

diff #

#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll n,k,m;
vector<ll> pri;
bool prijud(ll n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    int d[n+1];
    fill(d,d+n+1,-1);
    int cnt=0;
    int win=0;
    for(;;){
        if(cnt==n-1)break;
        int now=0;
        rep(i,1,n+1){
            if(d[i]>0)continue;
            if(now==0)now=i;
            else{
                cout<<"? "<<now<<" "<<i<<endl;
                int y;cin>>y;
                win=y;
                if(y==now)d[i]=now;
                else d[now]=i;
                now=0;
                cnt++;
            }
        }
    }
    vector<int> v;
    rep(i,1,n+1){
        if(d[i]==win)v.push_back(i);
    }
    int t[v.size()];
    fill(t,t+v.size(),0);
    rep(i,0,v.size()-1){
        rep(j,i+1,v.size()){
            cout<<"? "<<v[i]<<" "<<v[j]<<endl;
            int y;cin>>y;
            if(v[i]==y)t[i]++;
            else t[j]++;
        }
    }
    int num;
    int ma=-1;
    rep(i,0,v.size()){
        if(ma<t[i]){
            ma=t[i];
            num=v[i];
        }
    }
    cout<<"! "<<num<<endl;
}
0