#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;
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:40:22: error: 'cnt' was not declared in this scope; did you mean 'cnt1'?
40 | while (i <= cnt0 && cnt <= 10){
| ^~~
| cnt1
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++)
| ~^~~~~~~~~~~~