답안 #1030758

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1030758 2024-07-22T09:31:55 Z coolboy19521 Data Transfer (IOI19_transfer) C++17
0 / 100
4 ms 2420 KB
#include "transfer.h"
#include "iostream"

using namespace std;

vector<int> solve63(vector<int>& data) {
    int xsl = 0;
    int xsr = 0;
    for (int i = 63; i < 70; i ++)
        xsr |= data[i] * (1 << (i - 63));
    for (int i = 1; i <= 63; i ++)
        xsl ^= data[i - 1] * i;
    //cout << xsl << ' ' << xsr << '\n';
    for (int i = 1; i <= 63; i ++) {
        int val = (xsl ^ i) << 1;
        if (val == xsr) {
            //cout << "F: " << i << '\n';
            vector<int> an;
            for (int j = 0; j < i - 1; j ++)
                an.push_back(data[j]);
            an.push_back(1 - data[i - 1]);
            for (int j = i; j < 63; j ++)
                an.push_back(data[j]);
            return an;
        }
    }
    vector<int> an;
    for (int i = 0; i < 63; i ++)
        an.push_back(data[i]);
    return an;
}

vector<int> solve255(vector<int>& data) {
    int xsl = 0;
    int xsr = 0;
    for (int i = 255; i < 264; i ++)
        xsr |= data[i] * (1 << (i - 255));
    for (int i = 1; i <= 255; i ++)
        xsl ^= data[i - 1] * i;
    //cout << xsl << ' ' << xsr << '\n';
    for (int i = 1; i <= 255; i ++) {
        int val = (xsl ^ i) << 1;
        if (val == xsr) {
            //cout << "F: " << i << '\n';
            vector<int> an;
            for (int j = 0; j < i - 1; j ++)
                an.push_back(data[j]);
            an.push_back(1 - data[i - 1]);
            for (int j = i; j < 255; j ++)
                an.push_back(data[j]);
            return an;
        }
    }
    vector<int> an;
    for (int i = 0; i < 255; i ++)
        an.push_back(data[i]);
    return an;
}

vector<int> get_attachment(vector<int> source) {
    int n = source.size();
    int xs = 0;

    for (int i = 1; i <= n; i ++)
        xs ^= source[i - 1] * i;
    xs <<= 1;

    //cout << xs << '\n';

    vector<int> v;
    if (63 == n)
        for (int i = 0; i < 7; i ++) {
            int b = 0 < (xs & (1 << i));
            v.push_back(b);
        }
    else
        for (int i = 0; i < 9; i ++) {
            int b = 0 < (xs & (1 << i));
            v.push_back(b);
        }
    return v;
}

vector<int> retrieve(vector<int> data) {
    int m = data.size();
    if (70 == m)
        return solve63(data);
    return solve255(data);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 788 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 2420 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -