#include "transfer.h"
#include "iostream"
using namespace std;
vector<int> solve63(vector<int>& data) {
int xsl = 0;
int xsr = 0;
for (int i = 63; i < 69; i ++)
xsr |= data[i] * (1 << (i - 63));
for (int i = 1; i <= 63; i ++)
xsl ^= data[i - 1] * i;
int ev = data[69];
vector<int> v(data.begin(), data.begin() + 63);
if (ev != (__builtin_popcount(xsr) & 1))
return v;
if (xsl == xsr) return v;
int vl = (xsl ^ xsr) - 1;
v[vl] = 1 - v[vl];
return v;
}
vector<int> solve255(vector<int>& data) {
int xsl = 0;
int xsr = 0;
for (int i = 255; i < 263; i ++)
xsr |= data[i] * (1 << (i - 255));
for (int i = 1; i <= 255; i ++)
xsl ^= data[i - 1] * i;
int ev = data[263];
vector<int> v(data.begin(), data.begin() + 255);
if (ev != (__builtin_popcount(xsr) & 1))
return v;
if (xsl == xsr) return v;
int vl = (xsl ^ xsr) - 1;
v[vl] = 1 - v[vl];
return v;
}
vector<int> get_attachment(vector<int> source) {
int n = source.size();
int xs = 0;
for (int i = 1; i <= n; i ++)
xs ^= source[i - 1] * i;
//cout << xs << '\n';
vector<int> v;
if (63 == n)
for (int i = 0; i < 6; i ++) {
int b = 0 < (xs & (1 << i));
v.push_back(b);
}
else
for (int i = 0; i < 8; i ++) {
int b = 0 < (xs & (1 << i));
v.push_back(b);
}
v.push_back(__builtin_popcount(xs) & 1);
return v;
}
vector<int> retrieve(vector<int> data) {
int m = data.size();
if (70 == m)
return solve63(data);
return solve255(data);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
796 KB |
Output is correct |
2 |
Correct |
1 ms |
800 KB |
Output is correct |
3 |
Correct |
1 ms |
792 KB |
Output is correct |
4 |
Correct |
1 ms |
800 KB |
Output is correct |
5 |
Correct |
2 ms |
792 KB |
Output is correct |
6 |
Correct |
1 ms |
792 KB |
Output is correct |
7 |
Correct |
2 ms |
800 KB |
Output is correct |
8 |
Correct |
1 ms |
800 KB |
Output is correct |
9 |
Correct |
2 ms |
792 KB |
Output is correct |
10 |
Correct |
2 ms |
1236 KB |
Output is correct |
11 |
Correct |
1 ms |
1212 KB |
Output is correct |
12 |
Correct |
1 ms |
792 KB |
Output is correct |
13 |
Correct |
2 ms |
780 KB |
Output is correct |
14 |
Correct |
2 ms |
792 KB |
Output is correct |
15 |
Correct |
2 ms |
792 KB |
Output is correct |
16 |
Correct |
1 ms |
800 KB |
Output is correct |
17 |
Correct |
1 ms |
784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
2508 KB |
Output is correct |
2 |
Correct |
23 ms |
2516 KB |
Output is correct |
3 |
Correct |
23 ms |
2516 KB |
Output is correct |
4 |
Correct |
24 ms |
2508 KB |
Output is correct |
5 |
Correct |
23 ms |
2508 KB |
Output is correct |
6 |
Correct |
24 ms |
2516 KB |
Output is correct |
7 |
Correct |
31 ms |
2508 KB |
Output is correct |
8 |
Correct |
24 ms |
2508 KB |
Output is correct |
9 |
Correct |
24 ms |
2516 KB |
Output is correct |
10 |
Correct |
23 ms |
2508 KB |
Output is correct |
11 |
Correct |
23 ms |
2508 KB |
Output is correct |
12 |
Correct |
24 ms |
2516 KB |
Output is correct |
13 |
Correct |
23 ms |
2508 KB |
Output is correct |
14 |
Correct |
23 ms |
2512 KB |
Output is correct |
15 |
Correct |
34 ms |
2508 KB |
Output is correct |
16 |
Correct |
23 ms |
2520 KB |
Output is correct |
17 |
Correct |
28 ms |
2504 KB |
Output is correct |
18 |
Correct |
32 ms |
2508 KB |
Output is correct |
19 |
Correct |
23 ms |
2504 KB |
Output is correct |