#include <bits/stdc++.h>
using namespace std;
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}
// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
public:
template<typename T>
_Debug& operator,(T val) {
cout << val << endl;
return *this;
}
};
#define debug _Debug(),
// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;
// ---------- END OF TEMPLATE ----------
#include "grader.h"
int bin(int l,int h,int p,int N) {
if (l == h) return l;
int n = l+h-p;
if (n == p) n++;
if (n < 1) n = 1;
else if (n > N) n = N;
int r = Guess(n);
if (p > n) r = -r;
if (r == -1) return bin(l,(p+n-1)/2,n,N);
else if (r == 0) return (p+n)/2;
else return bin((p+n)/2+1,h,n,N);
}
int rec(int h,int N) {
if (h == 1) return 1;
else if (h == 2) {
Guess(1);
int r = Guess(2);
if (r == -1) return 1;
else return 2;
}
else if (h == 3) {
Guess(1);
int r = Guess(3);
if (r == -1) return 1;
else if (r == 0) return 2;
else return 3;
}
Guess(1);
int r = Guess((h+1)/2);
if (r == -1) return rec((h+1)/4,N);
else if (r == 0) return (h+3)/4;
else return bin((h+7)/4,h,(h+1)/2,N);
}
int HC(int N) {
return rec(N,N);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
732 ms |
8204 KB |
Output is partially correct - alpha = 0.750000000000 |