이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "messy.h"
using namespace std;
#define bug(x) cout << #x << " " << x << endl;
// void add_element( string& s ){
// cout << "ADD: " << s << endl;
// }
// void compile_set(){
//
// }
// int check_element(string& s ){
// cout << "CHECK: " << s << endl;
// int x; cin >> x; return x;
// }
void add( int ini, int fim, int n ){
if( ini == fim ) return;
string base;
for( int i = 0; i < n; i++ ){
if( i < ini || fim < i ) base.push_back('1');
else base.push_back('0');
}
int mid = ( ini + fim )/2;
for( int i = ini; i <= mid; i++ ){
base[i] = '1';
add_element(base);
base[i] = '0';
}
add( ini, mid, n ); add( mid + 1, fim, n );
}
void solve( int ini, int fim, int n, vector<int>& known, vector<int>& unknown, vector<int>& resp ){
if( ini == fim ){ resp[unknown.back()] = ini; return; }
string base;
for( int i = 0; i < n; i++ ) base.push_back('0');
for( int x : known ) base[x] = '1';
vector<int> kl, kr, ul, ur;
for( int x : known ){ kl.push_back(x); kr.push_back(x); }
int mid = ( ini + fim )/2;
for( int x : unknown ){
base[x] = '1';
if( check_element(base) ){
ul.push_back(x);
kr.push_back(x);
}
else{
ur.push_back(x);
kl.push_back(x);
}
base[x] = '0';
}
solve( ini, mid, n, kl, ul, resp ); solve( mid + 1, fim, n, kr, ur, resp );
}
vector<int> restore_permutation(int n, int w, int r){
add(0, n - 1, n);
compile_set();
vector<int> resp(n), known, unknown;
for( int i = 0; i < n; i++ ) unknown.push_back(i);
solve( 0, n - 1, n, known, unknown, resp );
return resp;
}
// int main(){
// int n; cin >> n;
// vector<int> v = restore_permutation(n, 40, 40);
// cout << "V: ";
// for( int x : v ) cout << x << " ";
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |