Submission #643406

# Submission time Handle Problem Language Result Execution time Memory
643406 2022-09-22T02:19:01 Z christinelynn Zagonetka (COI18_zagonetka) C++17
9 / 100
47 ms 340 KB
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const ll MOD=1e9+7;
using namespace std;
ll N,a[105];
int main(){
  cin>>N;
  for(int i=1;i<=N;i++){
    cin>>a[i];
  }
  if(N<=6){
    ll p[105],minn[105],maks[105];
    for(int i=1;i<=N;i++){
      p[i]=i;
      minn[i]=a[i];
      maks[i]=a[i];
    }
    do{
      cout<<"query";
      for(int i=1;i<=N;i++){
        cout<<' '<<p[i];
      }
      cout<<endl;
      ll x;
      cin>>x;
      if(x==1){
        for(int i=1;i<=N;i++){
          if(p[i]<minn[i]){
//            cout<<"update minn"<<endl;
            for(int j=1;j<=N;j++){
              minn[j]=p[j];
            }
            break;
          }
          if(p[i]>minn[i]){
            break;
          }
        }
        for(int i=1;i<=N;i++){
          if(p[i]>maks[i]){
//            cout<<"update maks"<<endl;
            for(int j=1;j<=N;j++){
              maks[j]=p[j];
            }
            break;
          }
          if(p[i]<maks[i]){
            break;
          }
        }  
      }
    }while(next_permutation(p+1,p+N+1));
    cout<<"end"<<endl;
    for(int i=1;i<=N;i++){
      cout<<minn[i]<<' ';
    }
    cout<<endl;
    for(int i=1;i<=N;i++){
      cout<<maks[i]<<' ';
    }
    cout<<endl;
  }
  else{
    cout<<"query";
    for(int i=1;i<=N;i++){
      cout<<' '<<i;
    }
    cout<<endl;
    ll x;
    cin>>x;
    if(x==0){
      ll a,b;
      for(int i=1;i<=N-1;i++){
        for(int j=i+1;j<=N;j++){
          cout<<"query";
          for(int k=1;k<=N;k++){
            if(k==i){
              cout<<' '<<j;
            }
            else if(k==j){
              cout<<' '<<i;
            }
            else{
              cout<<' '<<k;
            }
          }
          cout<<endl;
          ll x;
          if(x==1){
            a=i;
            b=j;
          }
        }
      }
      cout<<"end"<<endl;
      for(int i=1;i<=a-1;i++){
        cout<<i<<' ';
      }
      for(int i=a+1;i<=b-1;i++){
        cout<<i<<' ';
      }
      cout<<b<<' '<<a<<' ';
      for(int i=b+1;i<=N;i++){
        cout<<i<<' ';
      }
      cout<<endl;
      for(int i=N;i>=b+1;i--){
        cout<<i<<' ';
      }
      cout<<b<<' '<<a<<' ';
      for(int i=b-1;i>=a+1;i--){
        cout<<i<<' ';
      }
      for(int i=a-1;i>=1;i--){
        cout<<i<<' ';
      }
      cout<<endl;
    }
    else{
      ll a,b;
      for(int i=1;i<=N-1;i++){
        for(int j=i+1;j<=N;j++){
          cout<<"query";
          for(int k=N;k>=1;k--){
            if(k==i){
              cout<<' '<<j;
            }
            else if(k==j){
              cout<<' '<<i;
            }
            else{
              cout<<' '<<k;
            }
          }
          cout<<endl;
          ll x;
          if(x==1){
            a=i;
            b=j;
          }
        }
      }
      cout<<"end"<<endl;
      for(int i=1;i<=a-1;i++){
        cout<<i<<' ';
      }
      cout<<a<<' '<<b<<' ';
      for(int i=a+1;i<=b-1;i++){
        cout<<i<<' ';
      }
      for(int i=b+1;i<=N;i++){
        cout<<i<<' ';
      }
      cout<<endl;
      for(int i=N;i>=b+1;i--){
        cout<<i<<' ';
      }
      for(int i=b-1;i>=a+1;i--){
        cout<<i<<' ';
      }
      cout<<a<<' '<<b<<' ';
      for(int i=a-1;i>=1;i--){
        cout<<i<<' ';
      }
      cout<<endl;
    }
  }
}

Compilation message

zagonetka.cpp: In function 'int main()':
zagonetka.cpp:92:11: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   92 |           if(x==1){
      |           ^~
zagonetka.cpp:140:11: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
  140 |           if(x==1){
      |           ^~
zagonetka.cpp:123:12: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
  123 |       ll a,b;
      |            ^
zagonetka.cpp:123:10: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
  123 |       ll a,b;
      |          ^
zagonetka.cpp:75:12: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   75 |       ll a,b;
      |            ^
zagonetka.cpp:75:10: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
   75 |       ll a,b;
      |          ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 2 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 9 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 336 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 47 ms 340 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -