This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "grader.h"
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))
using namespace std;
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
#ifdef wiwihorz
#define print(a...) cerr << "Line " << __LINE__ << ": ", kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
void kout() { cerr << endl; }
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...);}
#else
#define print(...) 0
#define vprint(...) 0
#endif
vector <int> findSequence (int N) {
vector<int> ans, a, b, q;
int id = 0, num = -1;
int mx1 = N / 2 + 1, mx2 = (N * 3) / 4 + 1;
// get num
rep(i, 1, mx1) {
q.push_back(0);
if(!isSubsequence(q)) {
num = i - 1;
break;
}
}
if(num == -1) {
id = 1, q.clear();
rep(i, 1, mx1) {
q.push_back(1);
if(!isSubsequence(q)) {
num = i - 1;
break;
}
}
}
// get wall
rep(i, 0, num) {
q.clear();
rep(j, 1, i) q.push_back(id);
q.push_back(!id);
rep(j, 1, num - i) q.push_back(id);
if(isSubsequence(q)) a.push_back(i);
}
// get wall num
b.assign(a.size(), 0);
int sz = a.size(), tot = 0;
rep(i, 0, signed(a.size()) - 1) {
rep(j, 1, mx2 - num) {
q.clear();
rep(k, 1, a[i]) q.push_back(id);
rep(k, 1, j) q.push_back(!id);
rep(k, 1, num - a[i]) q.push_back(id);
if(!isSubsequence(q)) {
b[i] = j - 1;
tot += j - 1;
break;
}
}
}
int left = N - num - tot, cur = 0;
rep(i, 0, sz - 1) if(!b[i]) b[i] = left;
rep(i, 0, sz - 1) {
while(cur < a[i]) ans.push_back(id), cur ++;
rep(j, 1, b[i]) ans.push_back(!id);
}
while(cur < num) ans.push_back(id), cur++;
return ans;
}
Compilation message (stderr)
hidden.cpp:5: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
5 | #pragma loop-opt(on)
|
hidden.cpp:19:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
19 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
| ^~~~
hidden.cpp:19:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
19 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
| ^~~~
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |