Submission #292103

# Submission time Handle Problem Language Result Execution time Memory
292103 2020-09-06T11:01:35 Z Autoratch Data Transfer (IOI19_transfer) C++14
0 / 100
8 ms 2500 KB
#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;

int ret[10],mxk,n;
vector<int> s;

void send(int l,int r,int k)
{
    if(l==r) return;
    mxk = max(mxk,k);
    int m = (l+r)/2,v = 0;
    for(int i = l;i <= m;i++) v^=s[i];
    ret[k]^=v;
    send(l,m,k+1),send(m+1,r,k+1);
}

vector<int> get_attachment(vector<int> source)
{
    s = source;
    for(int i = 0;i < 10;i++) ret[i] = 0;
    mxk = 0;
    send(0,source.size()-1,0);
    vector<int> tmp;
    for(int i = 0;i <= mxk;i++) tmp.push_back(ret[i]);
    int all = 0;
    for(int x : tmp) all^=x;
    tmp.push_back(all);
    return tmp;
}

int solve(int l,int r,int k)
{
    if(l==r) return l;
    int m = (l+r)/2;
    if(ret[k]!=s[n+k]) return solve(l,m,k+1);
    else return solve(m+1,r,k+1);
}

vector<int> retrieve(vector<int> data)
{
    if(data.size()>200) n = 255;
    else n = 63;
    int all = 0;
    for(int i = n;i < data.size();i++) all^=data[i];
    if(all)
    {
        vector<int> tmp;
        for(int i = 0;i < n;i++) tmp.push_back(data[i]);
        return tmp;
    }
    for(int i = 0;i < 10;i++) ret[i] = 0;
    mxk = 0;
    s = data;
    send(0,n,0);
    int idx = solve(0,n+1,0);
    idx--;
    vector<int> tmp;
    for(int i = 0;i < n;i++) tmp.push_back(data[i]);
    if(idx>=0 and idx<n) tmp[idx]^=1;
    return tmp;
}

Compilation message

transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:45:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i = n;i < data.size();i++) all^=data[i];
      |                   ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1144 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 2500 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -