답안 #247444

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

#include<iostream>
#include<vector>

using namespace std;

const int BITCnt = 8;

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 Partially correct 13 ms 1148 KB Partially correct
2 Partially correct 12 ms 1152 KB Partially correct
3 Partially correct 12 ms 1116 KB Partially correct
4 Partially correct 12 ms 984 KB Partially correct
5 Partially correct 12 ms 916 KB Partially correct
6 Partially correct 12 ms 1156 KB Partially correct
7 Partially correct 12 ms 1036 KB Partially correct
8 Partially correct 12 ms 1124 KB Partially correct
9 Partially correct 12 ms 1128 KB Partially correct
10 Partially correct 12 ms 996 KB Partially correct
11 Partially correct 11 ms 1036 KB Partially correct
12 Partially correct 12 ms 1148 KB Partially correct
13 Partially correct 12 ms 1024 KB Partially correct
14 Partially correct 12 ms 992 KB Partially correct
15 Partially correct 13 ms 1144 KB Partially correct
16 Partially correct 12 ms 1124 KB Partially correct
17 Partially correct 12 ms 1144 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 2520 KB Output is correct
2 Correct 77 ms 2680 KB Output is correct
3 Correct 75 ms 2644 KB Output is correct
4 Correct 81 ms 2632 KB Output is correct
5 Correct 100 ms 2496 KB Output is correct
6 Correct 98 ms 2644 KB Output is correct
7 Correct 95 ms 2664 KB Output is correct
8 Correct 80 ms 2648 KB Output is correct
9 Correct 73 ms 2668 KB Output is correct
10 Correct 73 ms 2668 KB Output is correct
11 Correct 69 ms 2648 KB Output is correct
12 Correct 73 ms 2672 KB Output is correct
13 Correct 71 ms 2656 KB Output is correct
14 Correct 70 ms 2636 KB Output is correct
15 Correct 76 ms 2524 KB Output is correct
16 Correct 73 ms 2664 KB Output is correct
17 Correct 78 ms 2676 KB Output is correct
18 Correct 78 ms 2664 KB Output is correct
19 Correct 75 ms 2524 KB Output is correct