답안 #247442

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

#include<iostream>
#include<vector>

using namespace std;

const int BITCnt = 11;

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 12 ms 1144 KB Partially correct
2 Partially correct 12 ms 1004 KB Partially correct
3 Partially correct 12 ms 1128 KB Partially correct
4 Partially correct 13 ms 1036 KB Partially correct
5 Partially correct 12 ms 1120 KB Partially correct
6 Partially correct 15 ms 1128 KB Partially correct
7 Partially correct 13 ms 1020 KB Partially correct
8 Partially correct 12 ms 1156 KB Partially correct
9 Partially correct 12 ms 1128 KB Partially correct
10 Partially correct 12 ms 1128 KB Partially correct
11 Partially correct 12 ms 1152 KB Partially correct
12 Partially correct 12 ms 1124 KB Partially correct
13 Partially correct 12 ms 1044 KB Partially correct
14 Partially correct 12 ms 1152 KB Partially correct
15 Partially correct 12 ms 1148 KB Partially correct
16 Partially correct 12 ms 1152 KB Partially correct
17 Partially correct 11 ms 1152 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 74 ms 2664 KB Partially correct
2 Partially correct 76 ms 2648 KB Partially correct
3 Partially correct 74 ms 2628 KB Partially correct
4 Partially correct 78 ms 2672 KB Partially correct
5 Partially correct 91 ms 2652 KB Partially correct
6 Partially correct 88 ms 2652 KB Partially correct
7 Partially correct 81 ms 2668 KB Partially correct
8 Partially correct 82 ms 2676 KB Partially correct
9 Partially correct 71 ms 2752 KB Partially correct
10 Partially correct 78 ms 2636 KB Partially correct
11 Partially correct 69 ms 2668 KB Partially correct
12 Partially correct 72 ms 2668 KB Partially correct
13 Partially correct 76 ms 2676 KB Partially correct
14 Partially correct 75 ms 2664 KB Partially correct
15 Partially correct 73 ms 2664 KB Partially correct
16 Partially correct 73 ms 2672 KB Partially correct
17 Partially correct 79 ms 2672 KB Partially correct
18 Partially correct 77 ms 2516 KB Partially correct
19 Partially correct 72 ms 2648 KB Partially correct