#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
bool is(int q_0, int q_1, bool ord)
{
vector<int> v;
if (ord)
{
for (int i = 0; i < q_1; i++)
v.push_back(1);
for (int i = 0; i < q_0; i++)
v.push_back(0);
}
else
{
for (int i = 0; i < q_0; i++)
v.push_back(0);
for (int i = 0; i < q_1; i++)
v.push_back(1);
}
return isSubsequence(v);
}
vector<int> findSequence (int n)
{
vector<int> ans;
int tot_0 = 0, tot_1 = 0;
if (is(0, n/2+1, 1))
{
for (int i = 1; i <= n/2; i++)
if (is(i, 0, 0))
tot_0 = i;
tot_1 = n-tot_0;
}
else
{
for (int i = 1; i <= n/2; i++)
if (is(0, i, 1))
tot_1 = i;
tot_0 = n-tot_1;
}
int qtd_0 = 0, qtd_1 = 0;
for (int i = 0; i < n; i++)
{
if (qtd_1+1 + tot_0-qtd_0 <= n/2+1)
{
if (is(tot_0-qtd_0, qtd_1+1, 1))
{
ans.push_back(1);
qtd_1++;
}
else
{
ans.push_back(0);
qtd_0++;
}
}
else
{
if (is(qtd_0+1, tot_1-qtd_1, 0))
{
ans.push_back(0);
qtd_0++;
}
else
{
ans.push_back(1);
qtd_1++;
}
}
}
return ans;
}
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++)
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct: Maximum length of a query = 5 |
2 |
Correct |
1 ms |
256 KB |
Output is correct: Maximum length of a query = 6 |
3 |
Correct |
1 ms |
256 KB |
Output is correct: Maximum length of a query = 5 |
4 |
Correct |
1 ms |
256 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct: Maximum length of a query = 83 |
2 |
Correct |
5 ms |
384 KB |
Output is correct: Maximum length of a query = 90 |
3 |
Correct |
6 ms |
256 KB |
Output is correct: Maximum length of a query = 96 |
4 |
Correct |
4 ms |
384 KB |
Output is correct: Maximum length of a query = 77 |
5 |
Correct |
7 ms |
256 KB |
Output is correct: Maximum length of a query = 95 |
6 |
Correct |
5 ms |
256 KB |
Output is correct: Maximum length of a query = 87 |
7 |
Correct |
7 ms |
256 KB |
Output is correct: Maximum length of a query = 97 |
8 |
Correct |
5 ms |
256 KB |
Output is correct: Maximum length of a query = 83 |
9 |
Correct |
8 ms |
256 KB |
Output is correct: Maximum length of a query = 101 |
10 |
Correct |
8 ms |
256 KB |
Output is correct: Maximum length of a query = 100 |
11 |
Correct |
4 ms |
376 KB |
Output is correct: Maximum length of a query = 96 |
12 |
Correct |
7 ms |
256 KB |
Output is correct: Maximum length of a query = 100 |
13 |
Correct |
8 ms |
256 KB |
Output is correct: Maximum length of a query = 101 |