QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#724571#2829. CryptographymaspyAC ✓114ms3996kbC++239.1kb2024-11-08 13:49:412024-11-08 13:49:42

Judging History

你现在查看的是最新测评结果

  • [2024-11-08 13:49:42]
  • 评测
  • 测评结果:AC
  • 用时:114ms
  • 内存:3996kb
  • [2024-11-08 13:49:41]
  • 提交

answer

#line 1 "/home/maspy/compro/library/my_template.hpp"
#if defined(LOCAL)
#include <my_template_compiled.hpp>
#else

// https://codeforces.com/blog/entry/96344
#pragma GCC optimize("Ofast,unroll-loops")
// いまの CF だとこれ入れると動かない?
// #pragma GCC target("avx2,popcnt")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i128 = __int128;
using u128 = unsigned __int128;
using f128 = __float128;

template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'010'000'000;
template <>
constexpr ll infty<ll> = 2'020'000'000'000'000'000;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * 2'000'000'000'000'000'000;
template <>
constexpr double infty<double> = infty<ll>;
template <>
constexpr long double infty<long double> = infty<ll>;

using pi = pair<ll, ll>;
using vi = vector<ll>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;

#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...) \
  vector<vector<vector<vector<type>>>> name(a, vector<vector<vector<type>>>(b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i)
#define overload4(a, b, c, d, e, ...) e
#define overload3(a, b, c, d, ...) d
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)

#define FOR_subset(t, s) for (ll t = (s); t >= 0; t = (t == 0 ? -1 : (t - 1) & (s)))
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define elif else if

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define stoi stoll

int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
int popcnt_sgn(int x) { return (__builtin_parity(x) & 1 ? -1 : 1); }
int popcnt_sgn(u32 x) { return (__builtin_parity(x) & 1 ? -1 : 1); }
int popcnt_sgn(ll x) { return (__builtin_parity(x) & 1 ? -1 : 1); }
int popcnt_sgn(u64 x) { return (__builtin_parity(x) & 1 ? -1 : 1); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }

template <typename T>
T floor(T a, T b) {
  return a / b - (a % b && (a ^ b) < 0);
}
template <typename T>
T ceil(T x, T y) {
  return floor(x + y - 1, y);
}
template <typename T>
T bmod(T x, T y) {
  return x - y * floor(x, y);
}
template <typename T>
pair<T, T> divmod(T x, T y) {
  T q = floor(x, y);
  return {q, x - q * y};
}

template <typename T, typename U>
T SUM(const vector<U> &A) {
  T sm = 0;
  for (auto &&a: A) sm += a;
  return sm;
}

#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()

template <typename T>
T POP(deque<T> &que) {
  T a = que.front();
  que.pop_front();
  return a;
}
template <typename T>
T POP(pq<T> &que) {
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(pqg<T> &que) {
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(vc<T> &que) {
  T a = que.back();
  que.pop_back();
  return a;
}

template <typename F>
ll binary_search(F check, ll ok, ll ng, bool check_ok = true) {
  if (check_ok) assert(check(ok));
  while (abs(ok - ng) > 1) {
    auto x = (ng + ok) / 2;
    (check(x) ? ok : ng) = x;
  }
  return ok;
}
template <typename F>
double binary_search_real(F check, double ok, double ng, int iter = 100) {
  FOR(iter) {
    double x = (ok + ng) / 2;
    (check(x) ? ok : ng) = x;
  }
  return (ok + ng) / 2;
}

template <class T, class S>
inline bool chmax(T &a, const S &b) {
  return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
  return (a > b ? a = b, 1 : 0);
}

// ? は -1
vc<int> s_to_vi(const string &S, char first_char) {
  vc<int> A(S.size());
  FOR(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); }
  return A;
}

template <typename T, typename U>
vector<T> cumsum(vector<U> &A, int off = 1) {
  int N = A.size();
  vector<T> B(N + 1);
  FOR(i, N) { B[i + 1] = B[i] + A[i]; }
  if (off == 0) B.erase(B.begin());
  return B;
}

// stable sort
template <typename T>
vector<int> argsort(const vector<T> &A) {
  vector<int> ids(len(A));
  iota(all(ids), 0);
  sort(all(ids), [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
  return ids;
}

// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
  vc<T> B(len(I));
  FOR(i, len(I)) B[i] = A[I[i]];
  return B;
}

template <typename T, typename... Vectors>
void concat(vc<T> &first, const Vectors &... others) {
  vc<T> &res = first;
  (res.insert(res.end(), others.begin(), others.end()), ...);
}
#endif
#line 1 "/home/maspy/compro/library/other/io2.hpp"
#define INT(...)   \
  int __VA_ARGS__; \
  IN(__VA_ARGS__)
#define LL(...)   \
  ll __VA_ARGS__; \
  IN(__VA_ARGS__)
#define STR(...)      \
  string __VA_ARGS__; \
  IN(__VA_ARGS__)
#define CHR(...)    \
  char __VA_ARGS__; \
  IN(__VA_ARGS__)
#define DBL(...)           \
  long double __VA_ARGS__; \
  IN(__VA_ARGS__)

#define VEC(type, name, size) \
  vector<type> name(size);    \
  read(name)
#define VV(type, name, h, w)                     \
  vector<vector<type>> name(h, vector<type>(w)); \
  read(name)

void read(int &a) { cin >> a; }
void read(long long &a) { cin >> a; }
void read(char &a) { cin >> a; }
void read(double &a) { cin >> a; }
void read(long double &a) { cin >> a; }
void read(string &a) { cin >> a; }
template <class T, class S>
void read(pair<T, S> &p) {
  read(p.first), read(p.second);
}
template <class T>
void read(vector<T> &a) {
  for (auto &i: a) read(i);
}
template <class T>
void read(T &a) {
  cin >> a;
}
void IN() {}
template <class Head, class... Tail>
void IN(Head &head, Tail &... tail) {
  read(head);
  IN(tail...);
}

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &A) {
  os << A.fi << " " << A.se;
  return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &A) {
  for (size_t i = 0; i < A.size(); i++) {
    if (i) os << " ";
    os << A[i];
  }
  return os;
}

// chatgpt helped me
class CoutInitializer {
public:
  CoutInitializer() { std::cout << std::fixed << std::setprecision(15); }
};
static CoutInitializer cout_initializer;

void print() {
  cout << "\n";
  cout.flush();
}

template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
  cout << head;
  if (sizeof...(Tail)) cout << " ";
  print(forward<Tail>(tail)...);
}

void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
#line 3 "main.cpp"

void solve(ll N, ll Q) {
  vc<int> F(1 << N), G(1 << N), H(1 << N);
  FOR(x, 1 << N) read(F[x]);
  FOR(x, 1 << N) read(G[x]);
  FOR(x, 1 << N) read(H[x]);
  FOR(Q) {
    LL(a, b);
    b ^= H[a];
    a ^= G[b];
    b ^= F[a];
    print(b, a);
  }
}

signed main() {
  ll N, Q;
  while (cin >> N >> Q) { solve(N, Q); }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3608kb

input:

2 2
0 1 2 3
1 2 3 0
2 3 0 1
0 1
2 3
1 1
0 0
0 0
0 0
0 0

output:

3 0
1 2
0 0

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3480kb

input:

1 1
0 0
0 0
0 0
0 0

output:

0 0

result:

ok single line: '0 0'

Test #3:

score: 0
Accepted
time: 107ms
memory: 3600kb

input:

1 2
1 1
0 0
0 0
1 1
1 0
1 2
0 0
0 1
0 1
1 0
1 1
1 2
0 1
1 0
0 0
1 0
1 0
1 2
0 0
0 1
1 1
0 0
1 1
1 2
0 1
1 0
0 1
0 1
0 0
1 2
1 1
0 1
0 1
1 0
0 0
1 2
1 1
0 1
1 0
1 0
0 1
1 2
0 0
1 0
1 1
1 1
1 1
1 2
1 1
0 1
1 0
1 0
0 1
1 2
0 1
0 0
0 0
0 1
0 1
1 2
1 1
1 0
1 0
1 0
1 1
1 2
1 1
1 0
1 1
0 1
0 0
1 2
1 1
0 1
...

output:

0 1
1 1
1 0
0 1
0 0
0 0
1 1
0 1
1 0
1 1
0 0
1 0
1 1
1 0
0 0
0 0
1 1
1 0
1 0
1 0
1 0
0 1
1 1
0 0
0 1
0 1
1 0
1 1
0 1
1 0
0 1
0 1
1 0
0 1
1 1
1 1
0 0
0 1
0 1
1 0
1 1
1 0
0 1
1 1
0 1
0 0
1 1
0 1
1 1
0 1
0 0
0 1
1 1
0 0
0 0
1 1
0 0
1 1
1 1
0 1
0 1
0 0
1 1
1 1
0 1
1 0
0 0
1 1
1 0
1 1
1 0
0 1
0 1
1 0
1 1
...

result:

ok 100000 lines

Test #4:

score: 0
Accepted
time: 88ms
memory: 3840kb

input:

4 16
7 2 8 8 2 15 13 10 5 5 0 5 2 0 15 15
1 2 11 3 13 14 10 15 7 13 5 7 2 12 11 0
5 12 13 6 12 1 0 6 8 4 14 4 10 1 5 7
12 9
6 8
8 1
7 7
14 2
2 6
3 7
4 12
13 2
14 3
8 7
8 9
3 14
9 3
4 5
0 6
4 16
0 13 14 13 4 8 10 6 15 2 12 4 5 5 2 14
13 2 14 15 4 15 5 4 9 4 1 1 14 13 1 12
13 11 4 0 1 3 1 12 9 13 3 2 ...

output:

12 15
10 1
6 5
14 5
5 1
4 5
3 1
15 5
12 14
4 4
10 8
1 10
10 4
10 6
12 9
11 3
2 12
11 14
13 14
0 6
4 3
0 9
6 10
13 7
4 0
11 11
2 6
4 13
14 13
12 8
1 3
2 1
2 15
12 13
13 7
1 0
13 12
10 2
6 4
10 10
14 7
5 6
11 1
10 15
10 0
6 12
8 8
7 13
4 0
6 5
14 15
1 5
2 8
1 3
15 5
1 5
5 11
6 7
1 3
5 13
0 13
7 8
3 1
...

result:

ok 100000 lines

Test #5:

score: 0
Accepted
time: 96ms
memory: 3760kb

input:

8 256
215 131 208 99 201 160 182 162 164 214 234 9 157 250 72 41 220 245 229 229 254 69 135 244 148 124 40 99 162 192 119 16 33 74 86 48 125 231 93 201 23 122 86 57 196 120 191 173 76 106 75 171 236 110 97 137 212 183 155 243 170 9 73 105 6 62 236 190 244 195 187 154 117 27 33 249 253 91 60 171 246 ...

output:

150 90
167 182
101 211
252 124
138 91
180 74
249 14
139 45
94 47
211 139
242 81
67 44
59 54
185 200
248 130
230 186
94 23
108 151
104 135
249 204
163 22
154 32
35 151
221 218
251 253
225 201
210 207
107 208
143 70
68 251
99 87
58 232
136 12
12 47
71 115
196 46
161 28
244 123
77 219
30 188
127 154
16...

result:

ok 99840 lines

Test #6:

score: 0
Accepted
time: 114ms
memory: 3648kb

input:

12 4166
1983 2864 3575 3279 2856 2760 163 2429 1349 3670 2556 488 649 84 1670 3053 3755 1565 588 648 2341 2161 1370 1629 2488 3061 64 3632 1254 2481 2198 1901 119 1936 1394 1697 2037 227 3059 2046 303 3807 3002 4059 186 282 2924 2866 3691 1554 1329 33 2526 934 824 3690 3826 3995 3121 4082 2635 2072 ...

output:

3839 354
1928 1350
359 1198
3202 2673
3074 3386
1770 620
1549 2420
3830 2302
3366 123
1738 919
1468 1953
3092 3084
3521 506
1886 4078
2798 355
1093 1658
2375 3421
1130 1834
1261 3305
455 705
3488 1536
623 332
2733 1325
1483 3051
1745 2990
223 3906
1391 2327
1624 2551
2106 342
2589 1610
1943 505
194 ...

result:

ok 99984 lines

Test #7:

score: 0
Accepted
time: 112ms
memory: 3996kb

input:

16 100000
15763 61570 13635 125 23340 33047 56643 18557 57652 6444 31966 4480 16897 138 20790 46118 10271 37963 40670 8100 51402 7520 44128 38981 1655 63243 36023 50663 25419 1381 47573 4730 50082 31705 32542 22661 138 62375 13291 57761 19013 53858 17929 46331 23243 114 5175 13782 30789 61331 39083 ...

output:

36130 52724
54646 51235
38948 60084
5627 15129
15536 51595
58185 16800
51734 38696
59089 41260
63369 53230
32205 48405
21850 27390
552 1934
50279 11483
37562 8754
29895 22356
44864 29842
4479 15924
52332 64364
12570 36982
48149 17803
29034 6326
21909 60961
44408 47158
2438 7521
57197 34457
49306 306...

result:

ok 100000 lines