답안 #554588

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
554588 2022-04-28T20:11:45 Z urosk Data Transfer (IOI19_transfer) C++14
0 / 100
8 ms 4184 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;
    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

transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:60:12: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   60 |     if((n&1==1)&&ans[n/2]!=a.back()){
      |           ~^~~
transfer.cpp:47:17: warning: control reaches end of non-void function [-Wreturn-type]
   47 |     vector<int> b;
      |                 ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1036 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 4184 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -