QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#770895 | #4294. Bacteria | SorahISA | AC ✓ | 3ms | 7272kb | C++23 | 11.1kb | 2024-11-22 01:34:09 | 2024-11-22 01:34:10 |
Judging History
answer
#ifndef SorahISA
#define SorahISA
#include SorahISA __FILE__ SorahISA
void solve() {
int N; cin >> N;
int len = (1 << N), num = 1;
while ((len >> 1) >= 16) len >>= 1, num <<= 1;
while ((1 << len) > num) len >>= 1, num <<= 1;
// debug(len, num);
string ans;
set<pii> st;
for (int i = 0; i < (1<<len); ++i) {
if (~i & 1) st.ee(i, i+1);
for (int b = 0; b < len; ++b) ans += char((i >> b & 1) + '0');
}
for (int i = 0; i < (1<<len) and SZ(ans) < (1<<N); ++i) for (int j = 0; j < (1<<len); ++j) {
if (not st.ee(i, j).second) continue;
for (int b = 0; b < len; ++b) ans += char((i >> b & 1) + '0');
for (int b = 0; b < len; ++b) ans += char((j >> b & 1) + '0');
if (SZ(ans) == (1 << N)) break;
}
print(ans);
}
int32_t main() {
fastIO();
int t = 1; // cin >> t;
for (int _ = 1; _ <= t; ++_) {
// cout << "Case #" << _ << ": ";
solve();
}
return 0;
}
#else
#ifdef local
#define _GLIBCXX_DEBUG 1
#endif
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;
// #include <bits/extc++.h>
// #include <tr2/dynamic_bitset>
using i64 = long long;
using i128 = __int128;
#define int i64
using f80 = long double;
using f128 = __float128;
#define double f80
using pii = pair<int, int>;
template <typename T> using Prior = std::priority_queue<T>;
template <typename T> using prior = std::priority_queue<T, vector<T>, greater<T>>;
// #define X first
// #define Y second
#define eb emplace_back
#define ef emplace_front
#define ee emplace
#define pb pop_back
#define pf pop_front
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define SZ(x) ((int)(x).size())
// template <size_t D, typename T> struct Vec : vector<Vec<D-1, T>> {
// static_assert(D >= 1, "Vector dimension must be greater than zero!");
// template <typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D-1, T>>(n, Vec<D-1, T>(args...)) {}
// };
// template <typename T> struct Vec<1, T> : vector<T> {
// Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {}
// };
template <typename T> ostream& operator << (ostream &os, const vector<T> &vec)
{ for (size_t i = 0; i < size(vec); ++i) { if (i) os << " "; os << vec[i]; } return os; }
#ifdef local
#define fastIO() void()
#define debug(...) \
_color.emplace_back("\u001b[31m"), \
fprintf(stderr, "%sAt [%s], line %d: (%s) = ", _color.back().c_str(), __FUNCTION__, __LINE__, #__VA_ARGS__), \
_do(__VA_ARGS__), _color.pop_back(), \
fprintf(stderr, "%s", _color.back().c_str())
#define print(...) \
fprintf(stdout, "%s", "\u001b[36m"), \
_P(__VA_ARGS__), \
fprintf(stdout, "%s", "\u001b[0m")
deque<string> _color{"\u001b[0m"};
template <typename T> concept is_string = is_same_v<T, string&> or is_same_v<T, const string&>;
template <typename T> concept is_iterable = requires (T _t) { begin(_t); };
template <typename T> inline void _print_err(T &&_t);
template <typename T> inline void _print_err(T &&_t) requires is_iterable<T> and (not is_string<T>);
template <size_t I, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(const tuple<U...> &);
template <size_t I, typename ...U> inline typename enable_if<I < sizeof...(U), void>::type _print_err(const tuple<U...> &_t);
template <size_t I, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(tuple<U...> &);
template <size_t I, typename ...U> inline typename enable_if<I < sizeof...(U), void>::type _print_err(tuple<U...> &_t);
template <typename T, typename U> ostream& operator << (ostream &os, const pair<T, U> &_tu);
inline void _do() { cerr << "\n"; }
template <typename T> inline void _do(T &&_t) { _print_err(_t), cerr << "\n"; }
template <typename T, typename ...U> inline void _do(T &&_t, U &&..._u) { _print_err(_t), cerr << ", ", _do(_u...); }
#else
#define fastIO() cin.tie(0)->sync_with_stdio(0)
#define debug(...) void()
#define print(...) _P(__VA_ARGS__)
#endif
inline void _P() { cout << "\n"; }
template <typename T> inline void _P(T &&_t) { cout << _t << "\n"; }
template <typename T, typename ...U> inline void _P(T &&_t, U &&..._u) { cout << _t << " ", _P(_u...); }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int getRand(int L, int R) {
if (L > R) swap(L, R);
return (int)(rng() % ((uint64_t)R - L + 1) + L);
}
template <typename T, typename U> bool chmin(T &lhs, U rhs) { return lhs > rhs ? lhs = rhs, 1 : 0; }
template <typename T, typename U> bool chmax(T &lhs, U rhs) { return lhs < rhs ? lhs = rhs, 1 : 0; }
template <typename T> void make_unique(vector<T> &vec) {
if (not is_sorted(ALL(vec))) sort(ALL(vec));
vec.erase(unique(ALL(vec)), end(vec));
}
/// below are Fast I/O and _print_err templates ///
/*
/// Fast I/O by FHVirus ///
/// https://fhvirus.github.io/blog/2020/fhvirus-io/ ///
#include <unistd.h>
const int S = 65536;
int OP = 0;
char OB[S];
inline char RC() {
static char buf[S], *p = buf, *q = buf;
return p == q and (q = (p = buf) + read(0, buf, S)) == buf ? -1 : *p++;
}
inline int RI() {
static char c;
int a;
while (((c = RC()) < '0' or c > '9') and c != '-' and c != -1);
if (c == '-') {
a = 0;
while ((c = RC()) >= '0' and c <= '9') a *= 10, a -= c ^ '0';
}
else {
a = c ^ '0';
while ((c = RC()) >= '0' and c <= '9') a *= 10, a += c ^ '0';
}
return a;
}
inline void WI(int n, char c = '\n') {
static char buf[20], p;
if (n == 0) OB[OP++] = '0';
p = 0;
if (n < 0) {
OB[OP++] = '-';
while (n) buf[p++] = '0' - (n % 10), n /= 10;
}
else {
while (n) buf[p++] = '0' + (n % 10), n /= 10;
}
for (--p; p >= 0; --p) OB[OP++] = buf[p];
OB[OP++] = c;
if (OP > S-20) write(1, OB, OP), OP = 0;
}
/// Fast I/O by FHVirus ///
/// https://fhvirus.github.io/blog/2020/fhvirus-io/ ///
*/
#ifdef local
template <typename T> inline void _print_err(T &&_t) { cerr << _t; }
template <typename T> inline void _print_err(T &&_t) requires is_iterable<T> and (not is_string<T>) {
_color.emplace_back(_color.back()), ++_color.back()[3];
cerr << _color.back() << "[";
for (bool _first = true; auto &_x : _t) {
if (!_first) cerr << ", ";
_print_err(_x), _first = false;
}
cerr << "]" << (_color.pop_back(), _color.back());
}
template <typename T, typename U> ostream& operator << (ostream &os, const pair<T, U> &_tu) {
_color.emplace_back(_color.back()), ++_color.back()[3];
cerr << _color.back() << "(";
_print_err(_tu.first), cerr << ", ", _print_err(_tu.second);
cerr << ")" << (_color.pop_back(), _color.back());
return os;
}
template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(const tuple<U...> &) {
cerr << ")" << (_color.pop_back(), _color.back());
}
template <size_t I = 0, typename ...U> inline typename enable_if<I < sizeof...(U), void>::type _print_err(const tuple<U...> &_t) {
if (!I) {
_color.emplace_back(_color.back()), ++_color.back()[3];
cerr << _color.back();
}
cerr << (I ? ", " : "("), _print_err(get<I>(_t)), _print_err<I+1, U...>(_t);
}
template <size_t I = 0, typename ...U> inline typename enable_if<I == sizeof...(U), void>::type _print_err(tuple<U...> &) {
cerr << ")" << (_color.pop_back(), _color.back());
}
template <size_t I = 0, typename ...U> inline typename enable_if<I < sizeof...(U), void>::type _print_err(tuple<U...> &_t) {
if (!I) {
_color.emplace_back(_color.back()), ++_color.back()[3];
cerr << _color.back();
}
cerr << (I ? ", " : "("), _print_err(get<I>(_t)), _print_err<I+1, U...>(_t);
}
#endif
#endif
/**
*
*
*
* iiiiii iiiiiiiiii iiiiiiiiiiiiii
* iiiiiiiiiiiii iiiiiii iiii iiiiiiiiiiiiiii ii iiii
* iiiiiiii iiiiiiiii iiii iiii iii iii iiiiiiiiii
* iiiiiii iiiiii iiii iiii ii iiiiiiiiii iiii iiii
* iiiiii iiiii iiii iiii iii iiii iiiiiiiiiiiiiiiii ii
* iiiiii iiiiiii iiiiiii iiiiiiii iii iiiiiiiiiiiiii iii iiii
* iiiiii iiiiiii iiiii ii iiii iiiiiiiiiii iiii iii iiii iiii iii
* iiiii iiiiiiii ii iiiii iiii iiiiiiiii iii iii iii iii ii iiii
* iiiiii iiiiiiii iiiii iiiii iiiiiiiiiiiiiiii iii iii ii iii iii iiii
* iiiii iiiiii iiii iiiiii iiiiiii iii iii iiii ii i ii iii iii
* iiiiii iiii iiiiiiiiiiiiiii iii iiii iiiii iii ii iii iii ii
* iiiii iiiiiiii iiiiiiiiii iiii iiiiiiiii ii iii ii
* iiiii iiiiii iiii iiiii iii ii ii i
* iiiiii iiiiiiii iiiii iiiii ii ii ii
* iiiii iiii iiii iiiiiiiiiiii ii
* iii iiii iiii iiiiiiii
* iiiii iiii
* iiii iiii
* iiii iiiii
* iii iiiii
* iii iiiii
* iii iiiiii
* iiiiiiiii
* iiiiii
*
*
*
**/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
3
output:
00100111
result:
ok ja=9, pa=9
Test #2:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
1
output:
01
result:
ok ja=3, pa=3
Test #3:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
2
output:
0100
result:
ok ja=5, pa=5
Test #4:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
4
output:
0010011100000001
result:
ok ja=13, pa=13
Test #5:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
6
output:
0000100001001100001010100110111000011001010111010011101101111111
result:
ok ja=37, pa=37
Test #6:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
10
output:
000010000100110000101010011011100001100101011101001110110111111100000000000001000000110000000010000010100000011000001110000000010000100100000101000011010000001100001011000001110000111110000000100010001000010010001100100000101000101010000110100011101000000110001001100001011000110110000011100010111000...
result:
ok ja=277, pa=277
Test #7:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
5
output:
00100111000000010011100010101001
result:
ok ja=21, pa=21
Test #8:
score: 0
Accepted
time: 3ms
memory: 6136kb
input:
19
output:
000000001000000001000000110000000010000010100000011000001110000000010000100100000101000011010000001100001011000001110000111100000000100010001000010010001100100000101000101010000110100011101000000110001001100001011000110110000011100010111000011110001111100000000100100001000100010011000100001001001010...
result:
ok ja=65813, pa=65813
Test #9:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
7
output:
00001000010011000010101001101110000110010101110100111011011111110000000000000100000011000000001000001010000001100000111000000001
result:
ok ja=53, pa=53
Test #10:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
8
output:
0000100001001100001010100110111000011001010111010011101101111111000000000000010000001100000000100000101000000110000011100000000100001001000001010000110100000011000010110000011100001111100000001000100010000100100011001000001010001010100001101000111010000001
result:
ok ja=85, pa=85
Test #11:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
9
output:
000010000100110000101010011011100001100101011101001110110111111100000000000001000000110000000010000010100000011000001110000000010000100100000101000011010000001100001011000001110000111110000000100010001000010010001100100000101000101010000110100011101000000110001001100001011000110110000011100010111000...
result:
ok ja=149, pa=149
Test #12:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
11
output:
000000001000000001000000110000000010000010100000011000001110000000010000100100000101000011010000001100001011000001110000111100000000100010001000010010001100100000101000101010000110100011101000000110001001100001011000110110000011100010111000011110001111100000000100100001000100010011000100001001001010...
result:
ok ja=533, pa=533
Test #13:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
12
output:
000000001000000001000000110000000010000010100000011000001110000000010000100100000101000011010000001100001011000001110000111100000000100010001000010010001100100000101000101010000110100011101000000110001001100001011000110110000011100010111000011110001111100000000100100001000100010011000100001001001010...
result:
ok ja=789, pa=789
Test #14:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
13
output:
000000001000000001000000110000000010000010100000011000001110000000010000100100000101000011010000001100001011000001110000111100000000100010001000010010001100100000101000101010000110100011101000000110001001100001011000110110000011100010111000011110001111100000000100100001000100010011000100001001001010...
result:
ok ja=1301, pa=1301
Test #15:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
14
output:
000000001000000001000000110000000010000010100000011000001110000000010000100100000101000011010000001100001011000001110000111100000000100010001000010010001100100000101000101010000110100011101000000110001001100001011000110110000011100010111000011110001111100000000100100001000100010011000100001001001010...
result:
ok ja=2325, pa=2325
Test #16:
score: 0
Accepted
time: 1ms
memory: 3872kb
input:
15
output:
000000001000000001000000110000000010000010100000011000001110000000010000100100000101000011010000001100001011000001110000111100000000100010001000010010001100100000101000101010000110100011101000000110001001100001011000110110000011100010111000011110001111100000000100100001000100010011000100001001001010...
result:
ok ja=4373, pa=4373
Test #17:
score: 0
Accepted
time: 1ms
memory: 3808kb
input:
16
output:
000000001000000001000000110000000010000010100000011000001110000000010000100100000101000011010000001100001011000001110000111100000000100010001000010010001100100000101000101010000110100011101000000110001001100001011000110110000011100010111000011110001111100000000100100001000100010011000100001001001010...
result:
ok ja=8469, pa=8469
Test #18:
score: 0
Accepted
time: 0ms
memory: 4392kb
input:
17
output:
000000001000000001000000110000000010000010100000011000001110000000010000100100000101000011010000001100001011000001110000111100000000100010001000010010001100100000101000101010000110100011101000000110001001100001011000110110000011100010111000011110001111100000000100100001000100010011000100001001001010...
result:
ok ja=16661, pa=16661
Test #19:
score: 0
Accepted
time: 0ms
memory: 4676kb
input:
18
output:
000000001000000001000000110000000010000010100000011000001110000000010000100100000101000011010000001100001011000001110000111100000000100010001000010010001100100000101000101010000110100011101000000110001001100001011000110110000011100010111000011110001111100000000100100001000100010011000100001001001010...
result:
ok ja=33045, pa=33045
Test #20:
score: 0
Accepted
time: 0ms
memory: 7272kb
input:
20
output:
000000000000000010000000000000000100000000000000110000000000000000100000000000001010000000000000011000000000000011100000000000000001000000000000100100000000000001010000000000001101000000000000001100000000000010110000000000000111000000000000111100000000000000001000000000001000100000000000010010000000...
result:
ok ja=131349, pa=131349