This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=5e4+7, INF=1e9+7, C=10000;
int czy[2*LIM], lst=-1;
pair<int,int>dp[LIM];
bool pytaj(int x) {
czy[x]^=1;
int a=Query(x+1);
swap(a, lst);
return a!=lst;
}
void dc(vector<int>&X, vector<int>&Y) {
if(X.size()==1) {
Answer(X[0]+1, Y[0]+1);
return;
}
if(X.size()==2) {
pytaj(X[0]);
if(czy[X[0]]) swap(X[0], X[1]);
if(!pytaj(Y[0])) swap(Y[0], Y[1]);
Answer(X[0]+1, Y[0]+1);
Answer(X[1]+1, Y[1]+1);
return;
}
vector<int>AX, AY, BX, BY;
rep(i, dp[X.size()].nd) {
pytaj(X[i]);
AX.pb(X[i]);
}
for(int i=dp[X.size()].nd; i<X.size(); ++i) BX.pb(X[i]);
for(auto i : Y) if(czy[X[0]]==pytaj(i)) BY.pb(i); else AY.pb(i);
dc(AX, AY);
dc(BX, BY);
}
void Solve(int n) {
dp[2]={2, 0};
for(int i=3; i<=n; ++i) {
dp[i]={INF, INF};
for(int k=max(i/2-C, 1); k<min(i, i/2+C); ++k) dp[i]=min(dp[i], {i+k+dp[k].st+dp[i-k].st, k});
}
vector<int>X, Y;
rep(i, 2*n) {
if(pytaj(i)) X.pb(i);
else Y.pb(i);
}
dc(X, Y);
}
Compilation message (stderr)
minerals.cpp: In function 'void dc(std::vector<int>&, std::vector<int>&)':
minerals.cpp:36:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for(int i=dp[X.size()].nd; i<X.size(); ++i) BX.pb(X[i]);
| ~^~~~~~~~~
# | 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... |
# | 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... |