#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define ll long long
#define pb push_back
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ld long double
#define li __int128
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//mt19937 rng(54252763);
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<int D, typename T>struct vec : public vector<vec<D - 1, T>> {template<typename... Args>vec(int n = 0, Args... args) : vector<vec<D - 1, T>>(n, vec<D - 1, T>(args...)) {}};
template<typename T>struct vec<1, T> : public vector<T> {vec(int n = 0, T val = T()) : vector<T>(n, val) {}};
template<class T1,class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const deque<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T,greater<T> >& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T,greater<T> >& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
int ri(){int x;scanf("%i",&x);return x;}
void rd(int&x){scanf("%i",&x);}
void rd(long long&x){scanf("%lld",&x);}
void rd(double&x){scanf("%lf",&x);}
void rd(long double&x){scanf("%Lf",&x);}
void rd(string&x){cin>>x;}
void rd(char*x){scanf("%s",x);}
template<typename T1,typename T2>void rd(pair<T1,T2>&x){rd(x.first);rd(x.second);}
template<typename T>void rd(vector<T>&x){for(T&p:x)rd(p);}
template<typename C,typename...T>void rd(C&a,T&...args){rd(a);rd(args...);}
//istream& operator>>(istream& is,__int128& a){string s;is>>s;a=0;int i=0;bool neg=false;if(s[0]=='-')neg=true,i++;for(;i<s.size();i++)a=a*10+s[i]-'0';if(neg)a*=-1;return is;}
//ostream& operator<<(ostream& os,__int128 a){bool neg=false;if(a<0)neg=true,a*=-1;ll high=(a/(__int128)1e18);ll low=(a-(__int128)1e18*high);string res;if(neg)res+='-';if(high>0){res+=to_string(high);string temp=to_string(low);res+=string(18-temp.size(),'0');res+=temp;}else res+=to_string(low);os<<res;return os;}
vector<int> target;
bool isSubsequence(vector<int> s);
bool query(int ones, int zeros, int swap){
vector<int> q;
for(int i=0;i<ones;i++)
q.pb(1^swap);
for(int i=0;i<zeros;i++)
q.pb(0^swap);
return isSubsequence(q);
}
vector<int> findSequence(int n){
int limit = n/2 + 1;
int cntOne = -1;
for(int i=1;i<=limit&&cntOne==-1;i++)
if(!query(i,0,0))
cntOne=i-1;
for(int i=limit;i<=n&&cntOne==-1;i++)
if(query(0,n-i,0))
cntOne=i;
vector<int> ans(n,0);
for(int i=0;i<cntOne;i++){
int leftOne=i+1;
int pos=-1;
for(int j=1;j+leftOne<=limit&&pos==-1;j++)
if(!query(leftOne,j,0))
pos=n-cntOne+i-j+1;
int rightOne=cntOne-i;
for(int j=1;j+rightOne<=limit&&pos==-1;j++)
if(!query(j,rightOne,1))
pos=i+j-1;
if(pos==-1){
pos=i+limit-rightOne;
}
ans[pos]=1;
}
return ans;
}
Compilation message
hidden.cpp: In function 'int ri()':
hidden.cpp:34:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
34 | int ri(){int x;scanf("%i",&x);return x;}
| ~~~~~^~~~~~~~~
hidden.cpp: In function 'void rd(int&)':
hidden.cpp:35:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | void rd(int&x){scanf("%i",&x);}
| ~~~~~^~~~~~~~~
hidden.cpp: In function 'void rd(long long int&)':
hidden.cpp:36:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | void rd(long long&x){scanf("%lld",&x);}
| ~~~~~^~~~~~~~~~~
hidden.cpp: In function 'void rd(double&)':
hidden.cpp:37:24: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
37 | void rd(double&x){scanf("%lf",&x);}
| ~~~~~^~~~~~~~~~
hidden.cpp: In function 'void rd(long double&)':
hidden.cpp:38:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
38 | void rd(long double&x){scanf("%Lf",&x);}
| ~~~~~^~~~~~~~~~
hidden.cpp: In function 'void rd(char*)':
hidden.cpp:40:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | void rd(char*x){scanf("%s",x);}
| ~~~~~^~~~~~~~
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 |
200 KB |
Output is correct: Maximum length of a query = 5 |
2 |
Correct |
2 ms |
200 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 |
1 ms |
200 KB |
Output is correct: Maximum length of a query = 5 |
5 |
Correct |
1 ms |
200 KB |
Output is correct: Maximum length of a query = 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
49 ms |
200 KB |
Output is correct: Maximum length of a query = 83 |
2 |
Correct |
59 ms |
200 KB |
Output is correct: Maximum length of a query = 90 |
3 |
Correct |
77 ms |
200 KB |
Output is correct: Maximum length of a query = 96 |
4 |
Correct |
34 ms |
200 KB |
Output is correct: Maximum length of a query = 77 |
5 |
Correct |
79 ms |
200 KB |
Output is correct: Maximum length of a query = 95 |
6 |
Correct |
42 ms |
328 KB |
Output is correct: Maximum length of a query = 87 |
7 |
Correct |
50 ms |
200 KB |
Output is correct: Maximum length of a query = 97 |
8 |
Correct |
43 ms |
296 KB |
Output is correct: Maximum length of a query = 83 |
9 |
Correct |
104 ms |
200 KB |
Output is correct: Maximum length of a query = 101 |
10 |
Correct |
116 ms |
296 KB |
Output is correct: Maximum length of a query = 100 |
11 |
Correct |
63 ms |
200 KB |
Output is correct: Maximum length of a query = 96 |
12 |
Correct |
89 ms |
328 KB |
Output is correct: Maximum length of a query = 100 |
13 |
Correct |
122 ms |
200 KB |
Output is correct: Maximum length of a query = 101 |