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 <bits/stdc++.h>
#include "cave.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define F first
#define S second
#define pb push_back
//int tryCombination(vector<int> S);
//void answer(vector<int> S,vector<int> D);
bool vis[5005];
void exploreCave(int N)
{
int n=N;
int a[n],tmp[n],tmp2[n],s[n],d[n];
rep(i,n) a[i]=0;
rep(i,n)
{
bool x=0;
if(tryCombination(a)==i) x=1;
vector<int> pos;
rep(i,n) tmp[i]=a[i];
if(x)
{
rep(i,n) if(!vis[i]) tmp[i]=1;
}
rep(i,n) if(!vis[i]) pos.pb(i);
int l=0,r=pos.size()-1;
while(l<r)
{
int mid=l+r>>1;
rep(i,n) tmp2[i]=tmp[i];
for(int j=l;j<=mid;j++)
{
if(x) tmp2[pos[j]]=0;
else tmp2[pos[j]]=1;
}
if(tryCombination(tmp2)==i) r=mid;
else l=mid+1;
}
vis[l]=1;
s[l]=x;
d[l]=i;
a[l]=s[l];
}
answer(s,d);
}
Compilation message (stderr)
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:33:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
33 | int mid=l+r>>1;
| ~^~
# | 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... |