#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mid (l+r)/2
#define sz(a) int((a).size())
#define all(a) a.begin(),a.end()
#define mod 1000000007LL
#define pb push_back
#define endl "\n"
#define PRINT(x) cerr<<#x<<'-'<<x<<endl<<flush;
#define PRINTvec(x) { cerr<<#x<<"-"; for(int i=0;i<sz(x);i++) cerr<<x[i]<<" "; cerr<<endl; }
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define pb push_back
#define pf push_front
#define ppf pop_front
#define ppb pop_back
vector<int> to_bin(ll n,ll k){
vector<int> ret;
while(n!=0){
ret.pb(n%2);
n/=2;
}
for(int i=sz(ret);i<k;i++){
ret.pb(0);
}
return ret;
}
ll to_int(vector<int> bin){
ll ret=0;
for(int i=0;i<sz(bin);i++){
ret+=bin[i]*(1<<i);
}
return ret;
}
vector<int> get_attachment(vector<int> source){
ll n=sz(source);
ll k=(n==63 ? 6 : 8);
ll x=0;
ll odd=0;
vector<int> append;
for(int i=0;i<n;i++){
if(source[i]){
x^=(i+1);
}
}
append=to_bin(x,k);
for(int i=0;i<k;i++){
if(append[i]){
odd^=1;
}
}
append.pb(odd);
return append;
}
vector<int> retrieve(vector<int> data){
ll n=(sz(data)==70 ? 63 : 255);
ll k=(n==63 ? 6 : 8);
ll x=0;
ll pravix=0;
ll odd=data.back();
vector<int> bitsn(data.begin(),data.begin()+n),bitsk(data.begin()+n,data.end()-1);
pravix=to_int(bitsk);
for(int i=0;i<n;i++){
if(bitsn[i]){
x^=(i+1);
}
}
if(pravix==x){
return bitsn;
}
else if((count(all(bitsk),1)&1)==odd){
int idx=pravix^x;
bitsn[idx-1]^=1;
return bitsn;
}
else{
return bitsn;
}
}
Compilation message
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:68:8: warning: unused variable 'k' [-Wunused-variable]
68 | ll k=(n==63 ? 6 : 8);
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
620 KB |
Output is correct |
2 |
Correct |
3 ms |
620 KB |
Output is correct |
3 |
Correct |
3 ms |
620 KB |
Output is correct |
4 |
Correct |
3 ms |
632 KB |
Output is correct |
5 |
Correct |
3 ms |
620 KB |
Output is correct |
6 |
Correct |
4 ms |
620 KB |
Output is correct |
7 |
Correct |
3 ms |
692 KB |
Output is correct |
8 |
Correct |
3 ms |
616 KB |
Output is correct |
9 |
Correct |
4 ms |
620 KB |
Output is correct |
10 |
Correct |
3 ms |
620 KB |
Output is correct |
11 |
Correct |
3 ms |
632 KB |
Output is correct |
12 |
Correct |
3 ms |
620 KB |
Output is correct |
13 |
Correct |
3 ms |
620 KB |
Output is correct |
14 |
Correct |
4 ms |
620 KB |
Output is correct |
15 |
Correct |
3 ms |
620 KB |
Output is correct |
16 |
Correct |
3 ms |
620 KB |
Output is correct |
17 |
Correct |
3 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
57 ms |
2468 KB |
Output is correct |
2 |
Correct |
59 ms |
2468 KB |
Output is correct |
3 |
Correct |
65 ms |
2472 KB |
Output is correct |
4 |
Correct |
64 ms |
2468 KB |
Output is correct |
5 |
Correct |
72 ms |
2440 KB |
Output is correct |
6 |
Correct |
68 ms |
2468 KB |
Output is correct |
7 |
Correct |
66 ms |
2472 KB |
Output is correct |
8 |
Correct |
64 ms |
2472 KB |
Output is correct |
9 |
Correct |
53 ms |
2468 KB |
Output is correct |
10 |
Correct |
51 ms |
2472 KB |
Output is correct |
11 |
Correct |
50 ms |
2468 KB |
Output is correct |
12 |
Correct |
57 ms |
2468 KB |
Output is correct |
13 |
Correct |
56 ms |
2472 KB |
Output is correct |
14 |
Correct |
55 ms |
2480 KB |
Output is correct |
15 |
Correct |
59 ms |
2428 KB |
Output is correct |
16 |
Correct |
71 ms |
2468 KB |
Output is correct |
17 |
Correct |
63 ms |
2476 KB |
Output is correct |
18 |
Correct |
58 ms |
2428 KB |
Output is correct |
19 |
Correct |
56 ms |
2476 KB |
Output is correct |