# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
554588 | urosk | Data Transfer (IOI19_transfer) | C++14 | 8 ms | 4184 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "transfer.h"
#include <bits/stdc++.h>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
using namespace std;
vector<int> get_attachment(vector<int> a) {
int n = sz(a);
int x = 0;
vector<int> ans;
for(int i = 0;i<n;i++){
if(a[i]==0) x^=1;
}
ans.pb(x);
ans.pb(x);
int x1 = 0;
for(int i = 0;i<n/2;i++) x1^=a[i];
ans.pb(x1);
for(ll i = 0;i<n/2;i++) ans.pb(a[i]^a[n-i-1]);
if(n&1) ans.pb(a[n/2]);
return ans;
}
//n 4 n/2
vector<int> retrieve(vector<int> a) {
int m = sz(a);
int n = 1;
while(n+n/2+4<m) n+=2;
//cerr<<m<<" "<<n<<endl;
int x = 0;
for(int i = 0;i<n;i++){
if(a[i]==0) x^=1;
}
vector<int> b;
vector<int> ans;
b.pb(x);
b.pb(x);
int x1 = 0;
for(int i = 0;i<n/2;i++) x1^=a[i];
b.pb(x1);
for(ll i = 0;i<n/2;i++) b.pb(a[i]^a[n-i-1]);
b.pb(a[n/2]);
for(int i = 0;i<n;i++) ans.pb(a[i]);
if(a[n]!=a[n+1]){
return ans;
}
if((n&1==1)&&ans[n/2]!=a.back()){
ans[n/2]^=1;
return ans;
}
int x2 = a[n+2];
x1 = b[n+2];
ll e = 2;
if(x1!=x2) e = 1;
for(ll i = n+3;i<sz(b);i++){
if(b[i]!=a[i]){
int &x = ans[i-n];
int &y = ans[n-(i-n-3)-1];
if(e==1) x^=1;
else y^=1;
return ans;
}
}
}
/*
1
4 010101011
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |