Submission #554589

# Submission time Handle Problem Language Result Execution time Memory
554589 2022-04-28T20:20:07 Z urosk Data Transfer (IOI19_transfer) C++14
0 / 100
7 ms 2900 KB
#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;
    vector<int> b;
    vector<int> ans;
    int x = 0;
    for(int i = 0;i<n;i++){
        b.pb(a[i]);
        if(a[i]==0) x^=1;
    }
    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]);
    //for(int x : b) cerr<<x<< " ";
    //cerr<<endl;
    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;
    //cerr<<e<<endl;
    for(ll i = n+3;i<sz(b);i++){
        if(b[i]!=a[i]){
            int &x = ans[i-n-3];
            int &y = ans[n-(i-n-3)-1];
            //cerr<<i-n-3<<endl;
            if(e==1) x^=1;
            else y^=1;
            return ans;
        }
    }
}
/*
1
4 010101011
*/

Compilation message

transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:63:12: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   63 |     if((n&1==1)&&ans[n/2]!=a.back()){
      |           ~^~~
transfer.cpp:43:17: warning: control reaches end of non-void function [-Wreturn-type]
   43 |     vector<int> b;
      |                 ^
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 776 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 2900 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -