結果
| 問題 |
No.850 企業コンテスト2位
|
| コンテスト | |
| ユーザー |
ttttan2
|
| 提出日時 | 2019-07-05 22:52:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,735 bytes |
| コンパイル時間 | 1,248 ms |
| コンパイル使用メモリ | 164,028 KB |
| 実行使用メモリ | 25,476 KB |
| 平均クエリ数 | 216.14 |
| 最終ジャッジ日時 | 2024-07-16 17:29:08 |
| 合計ジャッジ時間 | 4,553 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 22 WA * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:81:17: warning: ‘num’ may be used uninitialized in this function [-Wmaybe-uninitialized]
81 | cout<<"! "<<num<<endl;
| ^~~
ソースコード
#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;
}
ttttan2