QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#688431 | #9518. 观虫我 (旧版数据) | cmk666 | 0 | 3909ms | 541440kb | C++23 | 10.8kb | 2024-10-30 09:04:08 | 2024-10-30 09:04:15 |
Judging History
answer
/* _ _ _ _ __ __ __
/ \ _ _ | |_ | |__ ___ _ __ _ ___ _ __ ___ | | __ / /_ / /_ / /_
/ _ \ | | | | | __| | '_ \ / _ \ | '__| (_) / __| | '_ ` _ \ | |/ / | '_ \ | '_ \ | '_ \
/ ___ \ | |_| | | |_ | | | | | (_) | | | _ | (__ | | | | | | | < | (_) | | (_) | | (_) |
/_/ \_\ \__,_| \__| |_| |_| \___/ |_| (_) \___| |_| |_| |_| |_|\_\ \___/ \___/ \___/
[Created Time: 2024-10-30 08:49:06]
[Last Modified Time: 2024-10-30 09:03:54] */
#ifdef LOCAL
#include<bits/stdc++.h>
#include"debug.h"
#else
#pragma GCC optimize("Ofast", "unroll-loops")
#include<bits/stdc++.h>
#define D(...) ((void)0)
#endif
using namespace std; using ll = long long;
#define For(i, j, k) for ( int i = (j) ; i <= (k) ; i++ )
#define Fol(i, j, k) for ( int i = (j) ; i >= (k) ; i-- )
namespace FastIO
{
#define USE_FastIO
// ------------------------------
// #define DISABLE_MMAP
// ------------------------------
#if ( defined(LOCAL) || defined(_WIN32) ) && !defined(DISABLE_MMAP)
#define DISABLE_MMAP
#endif
#ifdef LOCAL
inline void _chk_i() {}
inline char _gc_nochk() { return getchar(); }
inline char _gc() { return getchar(); }
inline void _chk_o() {}
inline void _pc_nochk(char c) { putchar(c); }
inline void _pc(char c) { putchar(c); }
template < int n > inline void _pnc_nochk(const char *c) { for ( int i = 0 ; i < n ; i++ ) putchar(c[i]); }
#else
#ifdef DISABLE_MMAP
inline constexpr int _READ_SIZE = 1 << 18; inline static char _read_buffer[_READ_SIZE + 40], *_read_ptr = nullptr, *_read_ptr_end = nullptr; static inline bool _eof = false;
inline void _chk_i() { if ( __builtin_expect(!_eof, true) && __builtin_expect(_read_ptr_end - _read_ptr < 40, false) ) { int sz = _read_ptr_end - _read_ptr; if ( sz ) memcpy(_read_buffer, _read_ptr, sz); char *beg = _read_buffer + sz; _read_ptr = _read_buffer, _read_ptr_end = beg + fread(beg, 1, _READ_SIZE, stdin); if ( __builtin_expect(_read_ptr_end != beg + _READ_SIZE, false) ) _eof = true, *_read_ptr_end = EOF; } }
inline char _gc_nochk() { return __builtin_expect(_eof && _read_ptr == _read_ptr_end, false) ? EOF : *_read_ptr++; }
inline char _gc() { _chk_i(); return _gc_nochk(); }
#else
#include<sys/mman.h>
#include<sys/stat.h>
inline static char *_read_ptr = (char *)mmap(nullptr, [] { struct stat s; return fstat(0, &s), s.st_size; } (), 1, 2, 0, 0);
inline void _chk_i() {}
inline char _gc_nochk() { return *_read_ptr++; }
inline char _gc() { return *_read_ptr++; }
#endif
inline constexpr int _WRITE_SIZE = 1 << 18; inline static char _write_buffer[_WRITE_SIZE + 40], *_write_ptr = _write_buffer;
inline void _chk_o() { if ( __builtin_expect(_write_ptr - _write_buffer > _WRITE_SIZE, false) ) fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout), _write_ptr = _write_buffer; }
inline void _pc_nochk(char c) { *_write_ptr++ = c; }
inline void _pc(char c) { *_write_ptr++ = c, _chk_o(); }
template < int n > inline void _pnc_nochk(const char *c) { memcpy(_write_ptr, c, n), _write_ptr += n; }
inline struct _auto_flush { inline ~_auto_flush() { fwrite(_write_buffer, 1, _write_ptr - _write_buffer, stdout); } } _auto_flush;
#endif
#define println println_ // don't use C++23 std::println
template < class T > inline constexpr bool _is_signed = numeric_limits < T >::is_signed;
template < class T > inline constexpr bool _is_unsigned = numeric_limits < T >::is_integer && !_is_signed < T >;
#if __SIZEOF_LONG__ == 64
template <> inline constexpr bool _is_signed < __int128 > = true;
template <> inline constexpr bool _is_unsigned < __uint128_t > = true;
#endif
inline bool _isgraph(char c) { return c >= 33; }
inline bool _isdigit(char c) { return 48 <= c && c <= 57; } // or faster, remove c <= 57
constexpr struct _table {
#ifndef LOCAL
int i[65536];
#endif
char o[40000]; constexpr _table() :
#ifndef LOCAL
i{},
#endif
o{} {
#ifndef LOCAL
for ( int x = 0 ; x < 65536 ; x++ ) i[x] = -1; for ( int x = 0 ; x <= 9 ; x++ ) for ( int y = 0 ; y <= 9 ; y++ ) i[x + y * 256 + 12336] = x * 10 + y;
#endif
for ( int x = 0 ; x < 10000 ; x++ ) for ( int y = 3, z = x ; ~y ; y-- ) o[x * 4 + y] = z % 10 + 48, z /= 10; } } _table;
template < class T, int digit > inline constexpr T _pw10 = 10 * _pw10 < T, digit - 1 >;
template < class T > inline constexpr T _pw10 < T, 0 > = 1;
inline void read(char &c) { do c = _gc(); while ( !_isgraph(c) ); }
inline void read_cstr(char *s) { char c = _gc(); while ( !_isgraph(c) ) c = _gc(); while ( _isgraph(c) ) *s++ = c, c = _gc(); *s = 0; }
inline void read(string &s) { char c = _gc(); s.clear(); while ( !_isgraph(c) ) c = _gc(); while ( _isgraph(c) ) s.push_back(c), c = _gc(); }
template < class T, bool neg >
#ifndef LOCAL
__attribute__((no_sanitize("undefined")))
#endif
inline void _read_int_suf(T &x) { _chk_i(); char c; while
#ifndef LOCAL
( ~_table.i[*reinterpret_cast < unsigned short *& >(_read_ptr)] ) if constexpr ( neg ) x = x * 100 - _table.i[*reinterpret_cast < unsigned short *& >(_read_ptr)++]; else x = x * 100 + _table.i[*reinterpret_cast < unsigned short *& >(_read_ptr)++]; if
#endif
( _isdigit(c = _gc_nochk()) ) if constexpr ( neg ) x = x * 10 - ( c & 15 ); else x = x * 10 + ( c & 15 ); }
template < class T, enable_if_t < _is_signed < T >, int > = 0 > inline void read(T &x) { char c; while ( !_isdigit(c = _gc()) ) if ( c == 45 ) { _read_int_suf < T, true >(x = -( _gc_nochk() & 15 )); return; } _read_int_suf < T, false >(x = c & 15); }
template < class T, enable_if_t < _is_unsigned < T >, int > = 0 > inline void read(T &x) { char c; while ( !_isdigit(c = _gc()) ); _read_int_suf < T, false >(x = c & 15); }
inline void write(bool x) { _pc(x | 48); }
inline void write(char c) { _pc(c); }
inline void write_cstr(const char *s) { while ( *s ) _pc(*s++); }
inline void write(const string &s) { for ( char c : s ) _pc(c); }
template < class T, bool neg, int digit > inline void _write_int_suf(T x) { if constexpr ( digit == 4 ) _pnc_nochk < 4 >(_table.o + ( neg ? -x : x ) * 4); else _write_int_suf < T, neg, digit / 2 >(x / _pw10 < T, digit / 2 >), _write_int_suf < T, neg, digit / 2 >(x % _pw10 < T, digit / 2 >); }
template < class T, bool neg, int digit > inline void _write_int_pre(T x) { if constexpr ( digit <= 4 ) if ( digit >= 3 && ( neg ? x <= -100 : x >= 100 ) ) if ( digit >= 4 && ( neg ? x <= -1000 : x >= 1000 ) ) _pnc_nochk < 4 >(_table.o + ( neg ? -x : x ) * 4); else _pnc_nochk < 3 >(_table.o + ( neg ? -x : x ) * 4 + 1); else if ( digit >= 2 && ( neg ? x <= -10 : x >= 10 ) ) _pnc_nochk < 2 >(_table.o + ( neg ? -x : x ) * 4 + 2); else _pc_nochk(( neg ? -x : x ) | 48); else { constexpr int cur = 1 << __lg(digit - 1); if ( neg ? x <= -_pw10 < T, cur > : x >= _pw10 < T, cur > ) _write_int_pre < T, neg, digit - cur >(x / _pw10 < T, cur >), _write_int_suf < T, neg, cur >(x % _pw10 < T, cur >); else _write_int_pre < T, neg, cur >(x); } }
template < class T, enable_if_t < _is_signed < T >, int > = 0 > inline void write(T x) { if ( x >= 0 ) _write_int_pre < T, false, numeric_limits < T >::digits10 + 1 >(x); else _pc_nochk(45), _write_int_pre < T, true, numeric_limits < T >::digits10 + 1 >(x); _chk_o(); }
template < class T, enable_if_t < _is_unsigned < T >, int > = 0 > inline void write(T x) { _write_int_pre < T, false, numeric_limits < T >::digits10 + 1 >(x), _chk_o(); }
template < size_t N, class ...T > inline void _read_tuple(tuple < T... > &x) { read(get < N >(x)); if constexpr ( N + 1 != sizeof...(T) ) _read_tuple < N + 1, T... >(x); }
template < size_t N, class ...T > inline void _write_tuple(const tuple < T... > &x) { write(get < N >(x)); if constexpr ( N + 1 != sizeof...(T) ) _pc(32), _write_tuple < N + 1, T... >(x); }
template < class ...T > inline void read(tuple < T... > &x) { _read_tuple < 0, T... >(x); }
template < class ...T > inline void write(const tuple < T... > &x) { _write_tuple < 0, T... >(x); }
template < class T1, class T2 > inline void read(pair < T1, T2 > &x) { read(x.first), read(x.second); }
template < class T1, class T2 > inline void write(const pair < T1, T2 > &x) { write(x.first), _pc(32), write(x.second); }
template < class T > inline auto read(T &x) -> decltype(x.read(), void()) { x.read(); }
template < class T > inline auto write(const T &x) -> decltype(x.write(), void()) { x.write(); }
template < class T1, class ...T2 > inline void read(T1 &x, T2 &...y) { read(x), read(y...); }
template < class ...T > inline void read_cstr(char *x, T *...y) { read_cstr(x), read_cstr(y...); }
template < class T1, class ...T2 > inline void write(const T1 &x, const T2 &...y) { write(x), write(y...); }
template < class ...T > inline void write_cstr(const char *x, const T *...y) { write_cstr(x), write_cstr(y...); }
template < class T > inline void print(const T &x) { write(x); }
inline void print_cstr(const char *x) { write_cstr(x); }
template < class T1, class ...T2 > inline void print(const T1 &x, const T2 &...y) { write(x), _pc(32), print(y...); }
template < class ...T > inline void print_cstr(const char *x, const T *...y) { write_cstr(x), _pc(32), print_cstr(y...); }
inline void println() { _pc(10); }
inline void println_cstr() { _pc(10); }
template < class ...T > inline void println(const T &...x) { print(x...), _pc(10); }
template < class ...T > inline void println_cstr(const T *...x) { print_cstr(x...), _pc(10); }
} using FastIO::read, FastIO::read_cstr, FastIO::write, FastIO::write_cstr, FastIO::println, FastIO::println_cstr;
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
template < class T > inline T R(T l, T r) { return uniform_int_distribution < T >(l, r)(rnd); }
using ui = unsigned; using ull = unsigned long long;
int n, q, o; char op[1000009]; ui x[1000009], y[1000009], a, b, c, s, t;
ull msk[64], z, f[1 << 26]; tuple < ull, ui, ui, ui > bst;
int main()
{
For(i, 0, 63) for ( int j = i ; ; j = ( j - 1 ) & i ) { msk[i] |= 1ull << j; if ( !j ) break; }
read(n, q), bst = tuple(1ull << 60, 0, 0, 0);
For(i, 1, q) read(op[i], x[i]), y[i] = x[i] & 63, x[i] >>= 6;
For(_, 1, 20)
{
a = b = c = z = 0;
For(i, 0, n - 7) o = R(1, 3), ( o == 1 ? a : o == 2 ? b : c ) |= 1u << i;
For(i, 1, q) z += 1u << __builtin_popcount(op[i] == '!' ? ( ~x[i] & b ) | ( x[i] & c )
: ( ~x[i] & c ) | ( x[i] & a ));
bst = min(bst, tuple(z, a, b, c));
}
tie(z, a, b, c) = bst;
For(i, 1, q)
if ( op[i] == '!' )
{
s = ( ~x[i] & b ) | ( x[i] & c ), t = x[i] & ( a | b ), z = 1ull << y[i];
for ( int j = s ; ; j = ( j - 1 ) & s ) { f[j | t] ^= z; if ( !j ) break; }
}
else
{
s = ( ~x[i] & c ) | ( x[i] & a ), t = x[i] & b, z = 0;
for ( int j = s ; ; j = ( j - 1 ) & s ) { z ^= f[j | t]; if ( !j ) break; }
println(__builtin_parity(z & msk[y[i]]));
}
return 0;
}
// 想上GM捏 想上GM捏 想上GM捏 想上GM捏 想上GM捏
// 伊娜可爱捏 伊娜贴贴捏
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 274ms
memory: 25268kb
input:
24 1000000 ! 9475137 ! 4501536 ? 14277831 ? 16695039 ? 5723102 ? 6093887 ? 3014539 ! 475969 ? 12500973 ! 8750136 ? 15617895 ! 4589313 ! 152300 ? 3612579 ? 15248179 ! 764162 ! 4461105 ? 7274495 ? 13299697 ! 8388872 ? 13490383 ! 3875594 ! 9439685 ? 16776189 ! 6443172 ? 13864879 ! 395691 ? 7142271 ? 16...
output:
1 1 0 0 0 1 0 0 0 1 0 0 1 1 0 0 1 1 1 1 0 1 1 1 0 0 0 0 1 0 1 0 0 0 1 0 1 1 0 1 1 1 0 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 0 1 1 0 0 1 1 0 0 1 0 0 0 1 0 0 1 1 0 1 1 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 0 0 1 1 0 0 1 0 1 0 0 1 1 1 0 1 1 1 1 0 0 0 1 0 1 1 1 0 0 0 0 1 0 1 1 1 0 0 0 1 1 0 ...
result:
wrong answer Wrong answer at operation #4: Incorrect answer.
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 413ms
memory: 31392kb
input:
26 1000000 ! 18006034 ? 66957270 ! 2133064 ! 147618 ! 34621442 ? 49715575 ? 62879287 ! 18620682 ? 67073751 ! 62941186 ! 7634532 ? 67100031 ? 12517237 ! 4804997 ? 65991126 ! 138275 ? 65722687 ? 66043391 ! 19147234 ? 45743743 ! 2242648 ! 44378336 ? 48226020 ! 34341926 ! 665045 ? 55433083 ! 5554254 ? 4...
output:
0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 0 1 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0 0 1 0 0 1 1 1 0 1 1 0 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 0 1 1 1 1 1 1 1 1 1 0 0 1 1 0 1 0 0 0 0 1 0 1 0 1 1 1 0 1 1 0 0 0 1 1 1 0 0 1 1 0 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 0 0 1 1 1 1 1 1 0 0 1 0 1 0 1 1 0 0 0 0 1 0 0 1 0 ...
result:
wrong answer Wrong answer at operation #18: Incorrect answer.
Subtask #3:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 665ms
memory: 57440kb
input:
28 1000000 ! 1081468 ! 128476263 ! 67930241 ? 94304031 ! 103698752 ! 19982 ! 198050624 ? 249519591 ? 71286719 ? 255700799 ! 103309888 ! 819340 ! 12852092 ? 124739445 ? 192734967 ! 101320328 ! 117594711 ? 252032927 ! 134267948 ? 262940285 ! 3155972 ? 267876218 ! 41984160 ? 246413294 ? 246824252 ? 163...
output:
0 0 1 0 1 0 0 0 0 0 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 0 1 1 1 0 0 0 0 1 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 1 1 0 0 1 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 0 1 0 0 1 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 1 0 1 1 1 0 0 1 1 0 0 1 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 1 0 1 0 1 0 0 0 1 0 1 1 1 0 0 1 1 1 0 1 ...
result:
wrong answer Wrong answer at operation #47: Incorrect answer.
Subtask #4:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 1806ms
memory: 156020kb
input:
30 1000000 ! 33852274 ? 1017904007 ? 1046413001 ! 151029382 ? 466826079 ? 250568375 ! 6769874 ! 2106474 ? 536832803 ? 209627867 ! 167104971 ? 1048372157 ! 245380745 ! 25174496 ? 819646460 ! 539548800 ! 671358165 ? 402955591 ? 527753201 ! 582494209 ? 862862931 ? 938974695 ? 263672827 ? 366968669 ? 87...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0 1 1 1 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 1 0 1 0 0 0 0 1 1 0 0 1 1 0 1 1 1 0 0 1 1 0 1 0 0 1 0 0 1 0 1 1 1 0 0 0 1 1 1 0 1 0 0 1 1 1 1 1 0 1 1 1 1 1 1 0 1 0 1 0 0 0 0 0 1 1 0 0 1 0 0 0 1 0 0 0 1 0 0 1 1 ...
result:
wrong answer Wrong answer at operation #59: Incorrect answer.
Subtask #5:
score: 0
Wrong Answer
Test #41:
score: 0
Wrong Answer
time: 3909ms
memory: 541440kb
input:
32 1000000 ! 2474971548 ! 348268033 ? 1055293046 ? 3382525679 ? 1805515707 ? 3210332902 ? 2805668987 ? 4025974780 ! 2217771280 ! 176949664 ! 4213841344 ! 1477473321 ? 3150869759 ? 2127418041 ! 1610631720 ! 3624477314 ! 2288149532 ! 70909964 ! 40117153 ! 1343751456 ? 3758095615 ! 513059275 ! 31956816...
output:
0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 1 0 0 0 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 1 1 0 0 0 1 0 0 0 1 1 0 0 1 1 1 0 0 1 1 0 0 0 0 0 0 0 1 0 0 1 1 0 1 0 1 0 0 1 1 0 1 1 1 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 1 0 0 1 0 1 1 0 0 0 1 1 0 1 1 0 0 ...
result:
wrong answer Wrong answer at operation #21: Incorrect answer.