#include<bits/stdc++.h>
#define pb push_back
#include "grader.h"
using namespace std;
vector <int> get(int x,int y,int c1,int c2){
vector <int> v;
for (int i = 1; i <= c1; i++)
v.pb(x);
for (int i = 1; i <= c2; i++)
v.pb(y);
return v;
}
vector <int> findSequence (int N){
int n = N;
int zero = 0, one = 1,cnt0 = 0,cnt1 = 0;
int lim = N / 2 + 1;
vector <int> vec(lim,0);
if (!isSubsequence(vec)){
for (int i = 1; i <= (N / 2); i++){
vector <int> v(i,0);
if (isSubsequence(v)) cnt0 = i;
}
cnt1 = N - cnt0;
}else{
for (int i = 1; i <= (N / 2); i++){
vector <int> v(i,1);
if (isSubsequence(v)) cnt0 = i;
}
cnt1 = N - cnt0;
zero = 1; one = 0;
}
//zero aris minimaluri raodenobit romelic gvxvdeba
vector <int> ans;
int i = 1,c1 = 0,cnt=0;
while (i <= cnt0 && cnt <= 10){
++cnt;
int len1 = i + cnt1 - c1;
if (len1 <= lim){
if (isSubsequence(get(zero,one,i,cnt1 - c1))) {
ans.pb(zero);
i += 1;
}else{
ans.pb(one);
c1 += 1;
}
continue;
}
if (isSubsequence(get(one,zero,c1+1,cnt0 - i + 1))){
ans.pb(one);
c1+=1;
}else{
ans.pb(zero);
i += 1;
}
}
while (c1 < cnt1) ans.pb(one),++c1;
return ans;
}
Compilation message
hidden.cpp: In function 'std::vector<int> findSequence(int)':
hidden.cpp:17:6: warning: unused variable 'n' [-Wunused-variable]
17 | int n = N;
| ^
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++)
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct: Maximum length of a query = 5 |
2 |
Correct |
0 ms |
344 KB |
Output is correct: Maximum length of a query = 6 |
3 |
Correct |
0 ms |
344 KB |
Output is correct: Maximum length of a query = 5 |
4 |
Correct |
0 ms |
344 KB |
Output is correct: Maximum length of a query = 5 |
5 |
Correct |
0 ms |
344 KB |
Output is correct: Maximum length of a query = 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output is not correct: The length of the returned sequence is not N |
2 |
Halted |
0 ms |
0 KB |
- |