QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#407390#8267. Staring ContestPhysics212303Compile Error//C++17706b2024-05-08 17:14:332024-05-08 17:14:34

Judging History

你现在查看的是最新测评结果

  • [2024-05-08 17:14:34]
  • 评测
  • [2024-05-08 17:14:33]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  int n; cin>>n;
  vector<int> p(n);
  iota(p.begin(),p.end(),0);
  shuffle(p.begin(),p.end(),mt19937(random_device()()));
  auto ask=[&](int x,int y){
    cout<<"? "<<x<<' '<<y<<endl;
    int r; cin>>r; return r;
  };
  int x=-1,y=-1,w=-1;
  for(int i:p){
    if(x<0)x=i;
    else if(y<0)y=i,w=ask(x,y);
    else{
      int o=ask(x,i),t;
      if(w<o)a[y]=w,y=i,w=o;
      else if(w>o)a[i]=o;
      else if((t=ask(y,i))==w)a[i]=a[x]=a[y]=w,x=y=-1;
      else a[x]=w,x=y,y=i,w=t;
    }
  }
  if(~x)a[x]; if(~y)a[y]=w;
  cout<<"! ";
  for(int i:a)cout<<i+1<<' ';
  cout<<endl;
  return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:19:14: error: ‘a’ was not declared in this scope
   19 |       if(w<o)a[y]=w,y=i,w=o;
      |              ^
answer.code:20:19: error: ‘a’ was not declared in this scope
   20 |       else if(w>o)a[i]=o;
      |                   ^
answer.code:21:31: error: ‘a’ was not declared in this scope
   21 |       else if((t=ask(y,i))==w)a[i]=a[x]=a[y]=w,x=y=-1;
      |                               ^
answer.code:22:12: error: ‘a’ was not declared in this scope
   22 |       else a[x]=w,x=y,y=i,w=t;
      |            ^
answer.code:25:9: error: ‘a’ was not declared in this scope
   25 |   if(~x)a[x]; if(~y)a[y]=w;
      |         ^
answer.code:25:21: error: ‘a’ was not declared in this scope
   25 |   if(~x)a[x]; if(~y)a[y]=w;
      |                     ^
answer.code:27:13: error: ‘a’ was not declared in this scope
   27 |   for(int i:a)cout<<i+1<<' ';
      |             ^