답안 #1006143

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1006143 2024-06-23T13:27:11 Z basa Data Transfer (IOI19_transfer) C++14
0 / 100
7 ms 4632 KB
#include <bits/stdc++.h>
#include "transfer.h"

using namespace std;

vector<int>get_attachment(vector<int>a)
{
  int eo = 0;
  int one = 0;
  int n = 255;

  vector<int>ret;
  for(int i = 0; i < n; i++){
    eo ^= a[i];
    if(a[i] == 1) one ^= i + 1;
    ret.push_back(a[i]);
  }

  for(int i = 7; i >= 0; i--){
    int bit = 1 << i;
    if(one >= bit){
      one -= bit;
      ret.push_back(1);
    }
    else ret.push_back(0);
  }
  ret.push_back(eo);

  return ret;
}

vector<int> retrieve(vector<int> data)
{
  int eo = 0;
  int back = 0;
  for(int i = 255; i < data.size() - 1; i++){
    eo ^= data[i];
    if(data[i]) back += 1 << (7 - (i - 255));
  }

  if(eo != data[255 + 9 - 1]) return vector<int>(data.begin(), data.end());

  int p = 0;
  for(int i = 0; i < 255; i++){
    if(data[i]) p ^= i + 1;
  }

  if((p ^ back) > 0) data[(p ^ back) - 1] = !data[(p ^ back) - 1];
  return data;
}

Compilation message

transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:36:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   for(int i = 255; i < data.size() - 1; i++){
      |                    ~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 788 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4632 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -