답안 #247441

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
247441 2020-07-11T11:54:26 Z stoyan_malinin Data Transfer (IOI19_transfer) C++14
60 / 100
13 ms 2668 KB
#include "transfer.h"
//#include "grader.cpp"

#include<iostream>
#include<vector>

using namespace std;

const int BITCnt = 6;

vector<int> get_attachment(vector<int> source)
{
    int val1 = 0, val2 = 0;
    for(int i = 0;i<source.size();i++)
    {
        if(source[i]==1)
        {
            val1 ^= 1;
            val2 ^= i + 1;
        }
    }

    vector <int> out;
    for(int bit = 0;bit<BITCnt;bit++) out.push_back(((val2>>bit)&1));
    out.push_back(val1);

    return out;
}

vector<int> retrieve(vector<int> data)
{
    vector <int> info;
    int val1 = 0, val2 = 0;
    int expectedVal1 = 0, expectedVal2 = 0;

    info = vector <int>(data.begin(), data.begin()+(data.size()-(BITCnt+1)));
    for(int i = 0;i<info.size();i++)
    {
        if(info[i]==1)
        {
            val1 ^= 1;
            val2 ^= i + 1;
        }
    }

    for(int i = (data.size()-(BITCnt+1));i<data.size()-1;i++) expectedVal2 += (data[i]<<(i-(data.size()-(BITCnt+1))));
    expectedVal1 = data.back();

    if(val1==expectedVal1 || val2==expectedVal2) return info;
    for(int i = 0;i<info.size();i++)
    {
        if((val2^(i+1))==expectedVal2)
        {
            info[i] ^= 1;
            return info;
        }
    }
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:14:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<source.size();i++)
                   ~^~~~~~~~~~~~~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:37:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<info.size();i++)
                   ~^~~~~~~~~~~~
transfer.cpp:46:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = (data.size()-(BITCnt+1));i<data.size()-1;i++) expectedVal2 += (data[i]<<(i-(data.size()-(BITCnt+1))));
                                          ~^~~~~~~~~~~~~~
transfer.cpp:50:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<info.size();i++)
                   ~^~~~~~~~~~~~
transfer.cpp:58:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1144 KB Output is correct
2 Correct 11 ms 1152 KB Output is correct
3 Correct 13 ms 920 KB Output is correct
4 Correct 12 ms 1040 KB Output is correct
5 Correct 12 ms 1148 KB Output is correct
6 Correct 12 ms 1040 KB Output is correct
7 Correct 12 ms 1140 KB Output is correct
8 Correct 12 ms 1140 KB Output is correct
9 Correct 12 ms 1148 KB Output is correct
10 Correct 12 ms 1152 KB Output is correct
11 Correct 12 ms 1148 KB Output is correct
12 Correct 12 ms 1144 KB Output is correct
13 Correct 12 ms 1156 KB Output is correct
14 Correct 12 ms 1152 KB Output is correct
15 Correct 12 ms 1272 KB Output is correct
16 Correct 12 ms 1040 KB Output is correct
17 Correct 12 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 2668 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -