#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wparentheses"
#include <bits/stdc++.h>
#include "grader.h"
#define all(i) (i).begin(), (i).end()
#define random random_device rd; mt19937 rng(rd())
using namespace std;
template<typename T1, typename T2>
ostream& operator << (ostream &i, pair<T1, T2> j) {
return i << j.first << ' ' << j.second;
}
template<typename T>
ostream& operator << (ostream &i, vector<T> j) {
i << '{' << j.size() << ':';
for (T ii : j) i << ' ' << ii;
return i << '}';
}
void Debug(bool _split) {}
template<typename T1, typename ...T2>
void Debug(bool _split, T1 x, T2 ...args) {
if (_split)
cerr << ", ";
cerr << x, Debug(true, args...);
}
template<typename T>
void Debuga(T *i, int n) {
cerr << '[';
for (int j = 0; j < n; ++j) cerr << i[j] << " ]"[j == n - 1];
cerr << endl;
}
#ifdef SYL
#define debug(args...) cerr << "Line(" << __LINE__ << ") -> [" << #args << "] is [", Debug(false, args), cerr << ']' << endl
#define debuga(i) cerr << "Line(" << __LINE__ << ") -> [" << #i << "] is ", Debuga(i, sizeof(i) / sizeof(typeid(*i).name()))
#else
#define debug(args...) void(0)
#define debuga(i) void(0)
#endif
typedef long long ll;
typedef pair<int, int> pi;
const int inf = 0x3f3f3f3f, lg = 20;
const ll mod = 1e9 + 7, INF = 0x3f3f3f3f3f3f3f3f;
bool isSubsequence(vector<int> s);
bool check(vector<int> s, vector<int> t) {
int it = 0;
for (int i : t) {
while (it < s.size() && s[it] != i)
++it;
if (it == s.size())
return false;
++it;
}
return true;
}
vector<int> findSequence(int n) {
if (n <= 10) {
vector<vector<int>> ans;
for (int i = 0; i < 1 << n; ++i) {
ans.emplace_back();
for (int j = 0; j < n; ++j)
ans.back().push_back(i >> j & 1);
}
vector<int> now;
int cnt = 1 << n;
function<void(int)> f = [&](int rem) {
bool tmp = isSubsequence(now);
for (vector<int> &i : ans)
if (!i.empty() && check(i, now) != tmp)
i.clear(), --cnt;
if (cnt == 1 || !tmp || !rem)
return;
now.push_back(0);
f(rem - 1);
if (cnt == 1)
return;
now.back() = 1;
f(rem - 1);
now.pop_back();
};
now.push_back(0);
f(n / 2);
if (cnt > 1)
now[0] = 1, f(n / 2);
for (vector<int> &i : ans)
if (!i.empty()) {
return i;
}
}
return vector<int>();
}
Compilation message
hidden.cpp: In function 'bool check(std::vector<int>, std::vector<int>)':
hidden.cpp:49:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | while (it < s.size() && s[it] != i)
| ~~~^~~~~~~~~~
hidden.cpp:51:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
51 | if (it == s.size())
| ~~~^~~~~~~~~~~
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++)
| ~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct: Maximum length of a query = 5 |
2 |
Correct |
2 ms |
276 KB |
Output is correct: Maximum length of a query = 6 |
3 |
Correct |
1 ms |
200 KB |
Output is correct: Maximum length of a query = 5 |
4 |
Correct |
2 ms |
328 KB |
Output is correct: Maximum length of a query = 5 |
5 |
Correct |
1 ms |
200 KB |
Output is correct: Maximum length of a query = 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Output is not correct: The length of the returned sequence is not N |
2 |
Halted |
0 ms |
0 KB |
- |