#include <bits/stdc++.h>
#include "grader.h"
//#define int ll
using namespace std;
#define ll long long
#define y1 zck_is_king
#define pii pair<ll, ll>
#define ull unsigned ll
#define f first
#define s second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define REP(i,n) for (int i = 0; i<n; ++i)
#define RREP(i,n) for (int i = n-1; i>=0; --i)
#define REP1(i,n) for (int i = 1; i<=n; ++i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"#%d (%s) = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif
const int iinf = 1e9+10;
const ll inf = 1ll<<60;
const ll mod = 1e9+7 ;
void GG(){cout<<"0\n"; exit(0);}
ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
ll re=1;
while (n>0){
if (n&1) re = re*a %mo;
a = a*a %mo;
n>>=1;
}
return re;
}
ll inv (ll b, ll mo = mod){
if (b==1) return b;
return (mo-mo/b) * inv(mo%b,mo) % mo;
}
const int maxn = 1e5+5;
using namespace std;
bool flip = 0;
#ifdef BALBIT
vector<int> yay = {0,1,0,0,0,1,0,1,1,1,0,1,0,0,0,0,1,0,0};
bool isSubsequence(vector<int> ar) {
int at = 0;
if (SZ(ar) == 0) return 1;
REP(i, SZ(yay)) {
if (yay[i] == ar[at]) {
++at; if (at == SZ(ar)) return 1;
}
}
return 0;
}
#endif // BALBIT
bool ask(vector<int> t) {
if (flip) {
for (int y : t) y ^= 1;
}
return isSubsequence(t);
}
vector < int > findSequence (int N)
{
vector < int > ans (N, 0);
int T0=0, T1=0;
// T0 is smaller than T1
// first figure out which is smaller
{
vector<int> hi;
REP(i, (N+1)/2) {
hi.pb(1);
}
if (ask(hi)) {
flip = 0; // 1 is more common
}else{
flip = 1;
}
bug("Flip?: ",flip);
}
// now try to figure out number of 0s and 1s, knowing that #0 <= #1
{
vector<int> hi;
while (1) {
hi.pb(0);
if (ask(hi)) {
++T0;
}else break;
}
}
T1 = N-T0;
bug(T0, T1);
{
vector<int> hi;
hi.pb(1);
REP(i,T0) hi.pb(0);
ans[0] = ask(hi);
}
int S0=0,S1=0;
if (ans[0] == 0) ++S0;
else ++S1;
REP1(i,N-1) {
if (ans[i-1]) {
// two cases
if (T1 - S1 + S0 < S1 + T0 - S0) {
// do back part
vector<int> hi;
REP(i,S0) hi.pb(0);
hi.pb(0); // !
REP(i,T1-S1) hi.pb(1);
ans[i] = !ask(hi);
}else{
// do front part
vector<int> hi;
REP(i,S1) hi.pb(1);
hi.pb(1);
REP(i,T0-S0) hi.pb(0);
ans[i] = ask(hi); // if yes, means 1 is ok to put here
}
}else{
// easy case
vector<int> hi;
REP(i, S0) hi.pb(0);
hi.pb(1);
REP(i, T0-S0) hi.pb(0);
ans[i] = ask(hi); // if yes, means there's something btw here
}
if (ans[i] == 0) ++S0;
else ++S1;
}
// for (int &x : ans) x ^= flip;
return ans;
}
#ifdef BALBIT
signed main(){
vector<int> yo = findSequence(SZ(yay));
for (int y : yo) cout<<y<<' ';
cout<<endl;
assert(yo == yay);
}
#endif
Compilation message
grader.cpp: In function 'int main()':
grader.cpp:28:26: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
28 | fprintf (fifo_out, "%d\n", ans.size ());
| ~^ ~~~~~~~~~~~
| | |
| int std::vector<int>::size_type {aka long unsigned int}
| %ld
grader.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for (int i=0; i<ans.size () && i < N; i++)
| ~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Output is correct: Maximum length of a query = 5 |
2 |
Correct |
1 ms |
300 KB |
Output is correct: Maximum length of a query = 6 |
3 |
Correct |
1 ms |
200 KB |
Output is correct: Maximum length of a query = 5 |
4 |
Correct |
2 ms |
284 KB |
Output is correct: Maximum length of a query = 5 |
5 |
Correct |
1 ms |
256 KB |
Output is correct: Maximum length of a query = 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
4 ms |
272 KB |
Output is partially correct: Maximum length of a query = 87 |
2 |
Partially correct |
9 ms |
204 KB |
Output is partially correct: Maximum length of a query = 96 |
3 |
Correct |
8 ms |
200 KB |
Output is correct: Maximum length of a query = 96 |
4 |
Partially correct |
6 ms |
204 KB |
Output is partially correct: Maximum length of a query = 78 |
5 |
Correct |
6 ms |
204 KB |
Output is correct: Maximum length of a query = 95 |
6 |
Correct |
8 ms |
344 KB |
Output is correct: Maximum length of a query = 87 |
7 |
Correct |
8 ms |
312 KB |
Output is correct: Maximum length of a query = 97 |
8 |
Correct |
7 ms |
216 KB |
Output is correct: Maximum length of a query = 83 |
9 |
Correct |
8 ms |
316 KB |
Output is correct: Maximum length of a query = 101 |
10 |
Correct |
9 ms |
340 KB |
Output is correct: Maximum length of a query = 100 |
11 |
Correct |
8 ms |
236 KB |
Output is correct: Maximum length of a query = 96 |
12 |
Correct |
7 ms |
476 KB |
Output is correct: Maximum length of a query = 100 |
13 |
Correct |
6 ms |
308 KB |
Output is correct: Maximum length of a query = 101 |