#include<bits/stdc++.h>
using namespace std;
#define pb push_back
vector<int> get_attachment(vector<int>a){
int i,v=0;
for(int u:a)v^=u;
a.pb(v);
return a;
}
vector<int>retrieve(vector<int>a){
int k=a.back(),v=0,u=0,i;
a.pop_back();
for(i=0;i<a.size()/2;i++){
v^=a[i];
u^=a[i+a.size()/2];
}
if(v==u){
a.resize(a.size()/2);
return a;
}
vector<int>ans;
for(i=0;i<a.size()/2;i++){
ans.pb(a[i+(v==k?0:(int)a.size()/2)]);
}
return ans;
}
/*
vector<int> get_attachment(vector<int> a){
int v=0,i,n=a.size(),cnt=0;
for(i=1;i<=n;i++)if(a[i-1])v^=i,cnt++;
vector<int>r;
for(i=(n<=63?5:7);i>=0;i--) r.pb((v>>i)&1);
r.pb(cnt&1);
return r;
}
vector<int>retrieve(vector<int> a){
int i,j,n=a.size(),k,v=0,u=0,cnt=0;
if(n<=70)n-=7,k=7;
else n=255,k=9;
for(i=1;i<=n;i++){
if(a[i-1])v^=i,cnt++;
}
for(i=0;i<k-1;i++){
u+=(a[i+n]<<(k-2-i));
}
if(u==v||(cnt&1)==a[n+k-1]){
a.resize(n);
return a;
}
a[(u^v)-1]^=1;
a.resize(n);
return a;
}
*/
/*
int main(){
int n;
cin>>n;
vector<int>v(n);
for(int i=0;i<n;i++)cin>>v[i];
vector<int>u=get_attachment(v);
for(int k:u)cout<<k<<' ';
cout<<'\n';
int k;
cin>>k;
u[k]^=1;
for(int u:retrieve(u))
cout<<u<<' ';
}
*/
Compilation message
transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:5:6: warning: unused variable 'i' [-Wunused-variable]
5 | int i,v=0;
| ^
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:13:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | for(i=0;i<a.size()/2;i++){
| ~^~~~~~~~~~~
transfer.cpp:22:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for(i=0;i<a.size()/2;i++){
| ~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
6 ms |
776 KB |
Partially correct |
2 |
Partially correct |
5 ms |
784 KB |
Partially correct |
3 |
Partially correct |
6 ms |
776 KB |
Partially correct |
4 |
Partially correct |
6 ms |
736 KB |
Partially correct |
5 |
Partially correct |
6 ms |
776 KB |
Partially correct |
6 |
Partially correct |
7 ms |
784 KB |
Partially correct |
7 |
Partially correct |
6 ms |
908 KB |
Partially correct |
8 |
Partially correct |
7 ms |
776 KB |
Partially correct |
9 |
Partially correct |
6 ms |
784 KB |
Partially correct |
10 |
Partially correct |
6 ms |
784 KB |
Partially correct |
11 |
Partially correct |
6 ms |
864 KB |
Partially correct |
12 |
Partially correct |
6 ms |
784 KB |
Partially correct |
13 |
Partially correct |
6 ms |
796 KB |
Partially correct |
14 |
Partially correct |
6 ms |
736 KB |
Partially correct |
15 |
Partially correct |
6 ms |
868 KB |
Partially correct |
16 |
Partially correct |
6 ms |
784 KB |
Partially correct |
17 |
Partially correct |
6 ms |
784 KB |
Partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
163 ms |
3072 KB |
Partially correct |
2 |
Partially correct |
167 ms |
3072 KB |
Partially correct |
3 |
Partially correct |
185 ms |
3208 KB |
Partially correct |
4 |
Partially correct |
176 ms |
3068 KB |
Partially correct |
5 |
Partially correct |
172 ms |
3208 KB |
Partially correct |
6 |
Partially correct |
183 ms |
3068 KB |
Partially correct |
7 |
Partially correct |
193 ms |
3048 KB |
Partially correct |
8 |
Partially correct |
204 ms |
3068 KB |
Partially correct |
9 |
Partially correct |
228 ms |
3200 KB |
Partially correct |
10 |
Partially correct |
185 ms |
3068 KB |
Partially correct |
11 |
Partially correct |
208 ms |
3072 KB |
Partially correct |
12 |
Partially correct |
205 ms |
3132 KB |
Partially correct |
13 |
Partially correct |
193 ms |
3188 KB |
Partially correct |
14 |
Partially correct |
194 ms |
3204 KB |
Partially correct |
15 |
Partially correct |
194 ms |
3016 KB |
Partially correct |
16 |
Partially correct |
190 ms |
3180 KB |
Partially correct |
17 |
Partially correct |
185 ms |
2992 KB |
Partially correct |
18 |
Partially correct |
180 ms |
3084 KB |
Partially correct |
19 |
Partially correct |
208 ms |
3212 KB |
Partially correct |