답안 #829908

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829908 2023-08-18T15:45:10 Z birthdaycake Data Transfer (IOI19_transfer) C++17
0 / 100
7 ms 4468 KB
#include<bits/stdc++.h>
#include "transfer.h"
using namespace std; 



vector<int> get_attachment(vector<int> source) {
    vector<int>d;
    int x1 = 0, x2 = 0;
    for(int i = 0; i < source.size(); i++){
        x1 ^= source[i];
        if(source[i] == 1) x2 ^= i;
        d.push_back(source[i]);
    }
    d.push_back(x1);
    for(int i = 0; i < 8; i++){
        if(x2 & (1 << i)) d.push_back(1);
        else d.push_back(0);
    }
    return d;
}

vector<int> retrieve(vector<int> data) {
    int x1 = 0, x2 = 0;
    if(data.size() == 72){
        for(int i = 0; i < 63; i++){
            x1 ^= data[i];
            if(data[i]) x2 ^= i;
        }
        vector<int>ans;
        if(x1 == data[63]){
            for(int i = 0; i < 63; i++) ans.push_back(data[i]);
            return ans;
        }else{
            int num = 0;
            for(int i = 64; i < data.size(); i++){
                if(data[i] == 1) num += (1 << (i - 64));
            }
            if(num == x2){
                for(int i = 0; i < 63; i++) ans.push_back(data[i]);
                return ans;
            }else{
                data[x2 ^ num] = !data[x2 ^ num];
                for(int i = 0; i < 63; i++) ans.push_back(data[i]);
                return ans;
            }
        }
   }else{
        for(int i = 0; i < 255; i++){
            x1 ^= data[i];
            if(data[i] == 1) x2 ^= i;
        }
        vector<int>ans;
        if(x1 == data[255]){
            for(int i = 0; i < 255; i++) ans.push_back(data[i]);
            return ans;
        }else{
            int num = 0;
            for(int i = 256; i < data.size(); i++){
                if(data[i] == 1) num += (1 << (i - 256));
            }
            if(num == x2){
                for(int i = 0; i < 255; i++) ans.push_back(data[i]);
                return ans;
            }else{
                data[x2 ^ num] = !data[x2 ^ num];
                for(int i = 0; i < 255; i++) ans.push_back(data[i]);
                return ans;
            }
        }
    }
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:10:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i = 0; i < source.size(); i++){
      |                    ~~^~~~~~~~~~~~~~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:36:31: 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 = 64; i < data.size(); i++){
      |                             ~~^~~~~~~~~~~~~
transfer.cpp:59:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |             for(int i = 256; i < data.size(); i++){
      |                              ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 936 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4468 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -