답안 #829649

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

std::vector<int> get_attachment(std::vector<int> source) {
    vector<int> v; int cnt = 0;
    for(int i = 0; i < source.size(); i++) {
       /// v.push_back(source[i]);
        if(source[i] == 1) cnt ^= i;
    }
    int cnt2 = 0;
    for(int i = 0; i < 8; i++) {
        if((cnt&(1<<i)) > 0) {
            v.push_back(1); cnt2++;
        }
        else {
            v.push_back(0);
        }
    }
    if(cnt2%2 == 0) v.push_back(0);
    else v.push_back(1);
    return v;
}

std::vector<int> retrieve(std::vector<int> data) {
    vector<int> v;
    int siz = data.size(); int a = 0, b = 0, cnt = 0;
    for(int i = 0; i < siz-9; i++) {
        v.push_back(data[i]);
        if(data[i] == 1) a ^= i;
    }
    for(int i = siz-9; i < siz-2; i++) {
        if(data[i] == 1) {
            b += (1<<(i-(siz-9))); cnt++;}
    }
    if(b == a) return v;
    if(cnt%2 != data[siz-1]) return v;
    int x = (a^b); v[x] ^= 1;
    return v;

}

Compilation message

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