#include<bits/stdc++.h>
using namespace std;
//#include "prize.h"
#include <vector>
int find_best(int n);
std::vector<int> ask(int i);
namespace solver{
map<int,pair<int,int> > mp;
int fin;
pair<int,int> query(int box){
if(box==-1){
return make_pair(0,-111);
}
if(mp.count(box))return mp[box];
cout<<"hering "<<box<<endl;
auto z=ask(box);
if(z[0]==0&&z[1]==0){
fin=box;
}
return mp[box]=make_pair(z[0],z[1]);
}
inline void dfs(int l,int r){
int ex=query(r-1).first-query(l-1).first;
int r_cn=query(r-1).first+query(r-1).second;
int l_cn=query(l-1).first+query(l-1).second;
if(r_cn==l_cn&&query(l-1).first+1==query(r).first)return;
if(l+1==r)return;
if(fin!=-1)return;
dfs(l,(l+r)>>1);
if(fin!=-1)return;
dfs((l+r)>>1,r);
}
int find_best(int n) {
fin=-1;
dfs(0,n);
return fin;
}
}
int find_best(int n) {
return solver::find_best(n);
}
Compilation message
prize.cpp: In function 'void solver::dfs(int, int)':
prize.cpp:27:7: warning: unused variable 'ex' [-Wunused-variable]
int ex=query(r-1).first-query(l-1).first;
^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
372 KB |
Token "hering" doesn't correspond to pattern "[A-B]{1}" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
460 KB |
Token "hering" doesn't correspond to pattern "[A-B]{1}" |
2 |
Halted |
0 ms |
0 KB |
- |