# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
995014 | TsotneSV | Library (JOI18_library) | C++14 | 43 ms | 596 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma gcc diagnostic "-std=c++1z"
#include <bits/stdc++.h>
#include "library.h"
using namespace std;
/* /\_/\
(= ._.)
/ > \>
*/
// #define int long long
#define fi first
#define se second
#define pb push_back
#define ins insert
#define mp make_pair
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(0);}
#define endl '\n'
#define sz(x) ((long long) (x).size())
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<" ";
#define printl(x) cout<<(x)<<endl
#define dbg(x) cerr<<#x<<" "<<x<<endl
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
void fileIO(string filename) {
freopen((filename + ".in").c_str(), "r", stdin);
freopen((filename + ".out").c_str(), "w", stdout);
}
// const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;
const int inf=1e9,MAXN=2e5+5;
const ll INF=1e18;
const ld pi = 3.14159265358979323846;
/*int Query(vector<int> &M) {
for(int i : M) print(i);
cout<<endl;
int q;
cin>>q;
return q;
}
void Answer(vector<int>& res) {
for(int i : res) print(i);
cout<<endl;
}*/
void Solve(int N){
vector<int> M(N,1),ans;
for(int i=1;i<=N;i++) {
M[i-1] = 0;
int q = Query(M);
M[i-1] = 1;
if(q == 1) {
ans.pb(i);
break;
}
}
vi leftover;
for(int i=1;i<=N;i++) {
if(i != ans.back()) leftover.pb(i);
}
for(int i=2;i<=N;i++) {
int l = 0,r = sz(leftover) - 1,idx = 0;
while(l <= r) {
M = vi(N,0); M[ans.back() - 1] = 1;
int mid = (l + r)/2;
for(int j=0;j<=mid;j++) {
M[leftover[j]-1] = 1;
}
int q1 = Query(M);
M[ans.back() - 1] = 0;
int q2 = Query(M);
if(q1 == q2) {
idx = mid;
r = mid - 1;
}else {
l = mid + 1;
}
}
ans.pb(leftover[idx]);
leftover.erase(leftover.begin() + idx);
}
Answer(ans);
}
/*
signed main() {
Solve(5);
}
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |