#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <cstring>
#include <climits>
#include <functional>
#include <cstdlib>
#include <complex>
#include <array>
#include <iomanip>
#include <bitset>
#define fileIO(name) if(fopen(name".in", "r")) {freopen(name".in", "r", stdin); freopen(name".out", "w", stdout);}
using namespace std;
const int MAXN = 2e5 + 111;
using ll = long long;
const int P = 31;
const ll mod1 = 1e9 + 7;
const ll mod2 = 998244353;
using ld = long double;
const ld EPS = 1e-5;
using pii = pair<int, int>;
const int K = 300;
vector<int> get_attachment(vector<int> source)
{
vector<int> res = source;
int x = 0;
for (int i = 0; i < source.size(); i++)
{
if (source[i])
x ^= (1 + i);
}
int odd = 0;
if (source.size() <= 63)
{
for (int i = 0; i < 6; i++)
{
if ((1 << i) & x)
odd++,res.push_back(1);
else
res.push_back(0);
}
res.push_back(odd & 1);
}
else
{
for (int i = 0; i < 8; i++)
if ((1 << i) & x)
odd++, res.push_back(1);
else
res.push_back(0);
res.push_back(odd & 1);
}
return res;
}
vector<int> retrieve(vector<int> data)
{
if (data.size() <= 63 + 7)
{
int par = data.back();
data.pop_back();
int x = 0;
int odd = 0;
for (int i = data.size()-6; i < data.size(); i++)
{
if (data[i])
odd++,x ^= (1 << i);
}
for (int i = 0; i < 6; i++)
data.pop_back();
if (par != odd)
return data;
int now = 0;
for (int i = 0; i < data.size(); i++)
if (data[i])
now ^= (i + 1);
int error = now ^ x;
data[error - 1] = 1 - data[error - 1];
}
else
{
int par = data.back();
data.pop_back();
int x = 0;
int odd = 0;
for (int i = data.size() - 8; i < data.size(); i++)
if (data[i])
odd++, x ^= (1 << i);
for (int i = 0; i < 8; i++)
data.pop_back();
if (par != odd)
return data;
int now = 0;
for (int i = 0; i < data.size(); i++)
if (data[i])
now ^= (i + 1);
int error = now ^ x;
data[error - 1] = 1 - data[error - 1];
}
return data;
}
Compilation message
transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:44:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for (int i = 0; i < source.size(); i++)
| ~~^~~~~~~~~~~~~~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:85:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
85 | for (int i = data.size()-6; i < data.size(); i++)
| ~~^~~~~~~~~~~~~
transfer.cpp:95:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
95 | for (int i = 0; i < data.size(); i++)
| ~~^~~~~~~~~~~~~
transfer.cpp:109:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
109 | for (int i = data.size() - 8; i < data.size(); i++)
| ~~^~~~~~~~~~~~~
transfer.cpp:118:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
118 | for (int i = 0; i < data.size(); i++)
| ~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1056 KB |
WA in grader: wrong source retrieval |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
4616 KB |
WA in grader: wrong source retrieval |
2 |
Halted |
0 ms |
0 KB |
- |