답안 #829625

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829625 2023-08-18T13:31:04 Z haxorman Data Transfer (IOI19_transfer) C++14
0 / 100
6 ms 2432 KB
#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> get_attachment(vector<int> source) {
    int end = 0;
    vector<int> res;
    for (int j = 0; (1 << j) < source.size(); ++j) {
        int val = 0;
        for (int i = 0; i < source.size(); ++i) {
            if (i & (1 << j)) {
                val ^= source[i];
            }
        }
        res.push_back(val);
        end ^= val;
    }
    res.push_back(end);

    return res;
}

vector<int> retrieve(vector<int> data) {
    if (data.size() > 255) {
        vector<int> source;
        for (int i = 0; i < data.size() - 9; ++i) {
            source.push_back(data[i]);
        }
        assert(source.size() == 255);
        
        int end = 0;
        vector<int> lst;
        for (int i = data.size() - 9; i < data.size() - 1; ++i) {
            lst.push_back(data[i]);
            end ^= data[i];
        }

        if (end != data.back()) {
            return source;
        }
        
        int bad = 0;
        for (int j = 0; (1 << j) < source.size(); ++j) {
            int val = 0;
            for (int i = 0; i < source.size(); ++i) {
                if (i & (1 << j)) {
                    val ^= source[i];
                }
            }

            if (val != lst[j]) {
                bad += (1 << j);
            }
        }

        source[bad] ^= 1;
        return source;
    }
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:8:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for (int j = 0; (1 << j) < source.size(); ++j) {
      |                     ~~~~~~~~~^~~~~~~~~~~~~~~
transfer.cpp:10:27: 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:26:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for (int i = 0; i < data.size() - 9; ++i) {
      |                         ~~^~~~~~~~~~~~~~~~~
transfer.cpp:33:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (int i = data.size() - 9; i < data.size() - 1; ++i) {
      |                                       ~~^~~~~~~~~~~~~~~~~
transfer.cpp:43:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for (int j = 0; (1 << j) < source.size(); ++j) {
      |                         ~~~~~~~~~^~~~~~~~~~~~~~~
transfer.cpp:45:31: 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 = 0; i < source.size(); ++i) {
      |                             ~~^~~~~~~~~~~~~~~
transfer.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
   59 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 892 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 2432 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -