#include "transfer.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define ft first
#define sd second
#define pi pair<int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dbg(...) dbg_out(__VA_ARGS__)
using ll = long long;
using ld = long double;
using namespace std;
using namespace __gnu_pbds;
//Constants
const ll INF = 5 * 1e18;
const int IINF = 2 * 1e9;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ld PI = 3.14159265359;
//Templates
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) {return os << '(' << p.first << ", " << p.second << ')';}
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) {os << '['; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << ']';}
void dbg_out() {cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << H << ' '; dbg_out(T...); }
template<typename T> void mins(T& x, T y) {x = min(x, y);}
template<typename T> void maxs(T& x, T y) {x = max(x, y);}
template<typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using omset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
vector<int> get_attachment(vector<int> source) {
int n = source.size();
int xor_cur = 0;
for (int i = 0; i < n; i++) {
if (source[i]) {
xor_cur ^= (i + 1);
}
}
vector<int> att;
int xxor = 0;
for (int i = 0; i < (n == 63 ? 6 : 8); i++) {
att.pb((xor_cur >> i) & 1);
xxor ^= att.back();
}
att.pb(xxor);
return att;
}
vector<int> retrieve(vector<int> data) {
int m = data.size(), n;
int xor_prev = 0; int xxor = 0; int cur = 0;
if (m < 255) {
n = 63;
for (int i = 63; i < 69; i++) {
cur ^= data[i];
if (data[i])
xor_prev |= (1 << (i - n));
}
xxor = data[69];
} else {
n = 255;
for (int i = 255; i < 263; i++) {
cur ^= data[i];
if (data[i])
xor_prev |= (1 << (i - n));
}
xxor = data[263];
}
vector<int> ans;
int xor_nw = 0;
for (int i = 0; i < n; i++) {
ans.pb(data[i]);
if (data[i]) {
xor_nw ^= (i + 1);
}
}
if (xxor != cur) {
return ans;
}
int pos = xor_nw ^ xor_prev;
if (pos != 0) {
ans[pos - 1] ^= 1;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
644 KB |
Output is correct |
2 |
Correct |
4 ms |
644 KB |
Output is correct |
3 |
Correct |
4 ms |
644 KB |
Output is correct |
4 |
Correct |
4 ms |
896 KB |
Output is correct |
5 |
Correct |
3 ms |
744 KB |
Output is correct |
6 |
Correct |
4 ms |
644 KB |
Output is correct |
7 |
Correct |
3 ms |
736 KB |
Output is correct |
8 |
Correct |
4 ms |
644 KB |
Output is correct |
9 |
Correct |
4 ms |
740 KB |
Output is correct |
10 |
Correct |
4 ms |
656 KB |
Output is correct |
11 |
Correct |
4 ms |
724 KB |
Output is correct |
12 |
Correct |
4 ms |
652 KB |
Output is correct |
13 |
Correct |
4 ms |
740 KB |
Output is correct |
14 |
Correct |
3 ms |
656 KB |
Output is correct |
15 |
Correct |
4 ms |
644 KB |
Output is correct |
16 |
Correct |
4 ms |
732 KB |
Output is correct |
17 |
Correct |
4 ms |
652 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
99 ms |
2460 KB |
Output is correct |
2 |
Correct |
95 ms |
2488 KB |
Output is correct |
3 |
Correct |
117 ms |
2500 KB |
Output is correct |
4 |
Correct |
100 ms |
2488 KB |
Output is correct |
5 |
Correct |
97 ms |
2488 KB |
Output is correct |
6 |
Correct |
96 ms |
2500 KB |
Output is correct |
7 |
Correct |
106 ms |
2452 KB |
Output is correct |
8 |
Correct |
98 ms |
2492 KB |
Output is correct |
9 |
Correct |
95 ms |
2500 KB |
Output is correct |
10 |
Correct |
94 ms |
2500 KB |
Output is correct |
11 |
Correct |
102 ms |
2492 KB |
Output is correct |
12 |
Correct |
95 ms |
2488 KB |
Output is correct |
13 |
Correct |
107 ms |
2500 KB |
Output is correct |
14 |
Correct |
102 ms |
2500 KB |
Output is correct |
15 |
Correct |
102 ms |
2488 KB |
Output is correct |
16 |
Correct |
94 ms |
2488 KB |
Output is correct |
17 |
Correct |
93 ms |
2448 KB |
Output is correct |
18 |
Correct |
98 ms |
2492 KB |
Output is correct |
19 |
Correct |
110 ms |
2488 KB |
Output is correct |