/*input
*/
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
namespace my_template {
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;
#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;
template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }
template<typename T>
void print(vector<T> vec, string name = "") {
cout << name;
for (auto u : vec)
cout << u << ' ';
cout << '\n';
}
}
using namespace my_template;
const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
int a, b;
vi ats;
int cntA;
int n;
bool isab(int c1, int c2) {
vi c(c1, a);
for (int i = 0; i < c2; ++i)
c.emplace_back(b);
return isSubsequence(c);
}
bool isba(int c1, int c2) {
vi c(c1, b);
for (int i = 0; i < c2; ++i)
c.emplace_back(a);
return isSubsequence(c);
}
void check() {
int z = 0;
int v = 0;
vi c;
for (int i = 0; i < n / 2; ++i)
{
c.emplace_back(0);
if (isSubsequence(c)) z++;
else break;
}
c.clear();
for (int i = 0; i < n / 2; ++i)
{
c.emplace_back(1);
if (isSubsequence(c)) v++;
else break;
}
if (z == v) {
assert(z == n / 2);
a = 1;
b = 0;
cntA = n / 2;
} else {
if (v > z) {
a = 1;
b = 0;
cntA = n - z;
} else {
a = 0;
b = 1;
cntA = n - v;
}
}
}
int lim;
vi findSequence(int N) {
n = N;
check();
lim = N / 2 + 1;
int sofarB = 0;
// printf("a = %d, cnt = %d\n", a, cntA);
for (int i = 0; i < cntA; ++i)
{
int kairejb = 0;
while (sofarB + kairejb + 1 + 1 + cntA - i - 1 <= lim and isba(sofarB + kairejb + 1, cntA - i - 1 + 1)) {
kairejb++;
}
int desinejb = 0;
while (i + 1 + desinejb + 1 <= lim and isab(i + 1, desinejb + 1)) {
desinejb++;
}
// printf("i = %d, kairejb = %d, desinejb = %d, vir = %d, ap = %d, lim = %d\n",
// i, kairejb, desinejb, sofarB + kairejb + 1 + 1 + cntA - i - 1,
// i + 1 + desinejb, lim);
if (sofarB + kairejb + 1 + 1 + cntA - i - 1 <= lim) {
for (int j = 0; j < kairejb; ++j)
ats.emplace_back(b);
sofarB += kairejb;
ats.emplace_back(a);
} else if (i + 1 + desinejb <= lim and isab(i + 1, desinejb)) {
int kairej = N - cntA - desinejb - sofarB;
for (int j = 0; j < kairej; ++j)
{
ats.emplace_back(b);
}
sofarB += kairej;
ats.emplace_back(a);
} else {
for (int j = 0; j < kairejb; ++j)
ats.emplace_back(b);
sofarB += kairejb;
ats.emplace_back(a);
}
}
return ats;
}
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 |
Incorrect |
1 ms |
256 KB |
Output is not correct: The length of the returned sequence is not N |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
62 ms |
256 KB |
Output is not correct: The length of the returned sequence is not N |
2 |
Halted |
0 ms |
0 KB |
- |