답안 #643456

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
643456 2022-09-22T04:31:49 Z andecaandeci Zagonetka (COI18_zagonetka) C++17
9 / 100
75 ms 312 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define db double
#define pairll pair<ll,ll>
#define lpairll pair<ll,pairll>

#define repp(i,a,b) for (ll i = a; i <= b; i++)
#define repz(i,a,b) for (ll i = a; i < b; i++)
#define repm(i,a,b) for (ll i = a; i >= b; i--)
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

const ll N = 5e5+5, MOD = 1e9+7;
ll tc = 1, n, m, ar[N], br[N], used[10];
ll x, y, k, need;
string s, s1, s2, ye = "YES", no = "NO";
vector<ll> v, ori, maxi, mini;

ll ask(vector<ll> &V){
  cout << "query ";
  for (auto i : V) cout << i << " ";
  cout << endl;
  ll bnk; cin >> bnk;
  return bnk;
}

void brt(ll idx){
  if (idx > n){
    ll ged = ask(v);
    if (ged == 1){
      maxi = max(maxi,v);
      mini = min(mini,v);
    }
    return;
  }
  repp(i,1,n){
    if (used[i]) continue;
    used[i] = 1;
    v.pb(i);
    brt(idx+1);
    used[i] = 0;
    v.pop_back();
  }
}

void input(){
  cin >> n;
  repp(i,1,n){
    cin >> m;
    ori.pb(m);
  }
  need = ask(ori);
  maxi = mini = ori;
}

void solve(){
  brt(1);
  cout << "end" << endl;
  for (auto i : mini) cout << i << " ";
  cout << endl;
  for (auto i : maxi) cout << i << " ";
  cout << endl; 
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  //cin >> tc;
  while(tc--){
    input();
    solve();
  }
}
# 결과 실행 시간 메모리 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 2 ms 208 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 8 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 36 ms 312 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 24 ms 304 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 75 ms 308 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -