Submission #247443

# Submission time Handle Problem Language Result Execution time Memory
247443 2020-07-11T11:55:46 Z stoyan_malinin Data Transfer (IOI19_transfer) C++14
68 / 100
98 ms 2764 KB
#include "transfer.h"
//#include "grader.cpp"

#include<iostream>
#include<vector>

using namespace std;

const int BITCnt = 15;

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]
 }
 ^
# Verdict Execution time Memory Grader output
1 Partially correct 12 ms 1148 KB Partially correct
2 Partially correct 12 ms 1144 KB Partially correct
3 Partially correct 12 ms 1152 KB Partially correct
4 Partially correct 12 ms 1152 KB Partially correct
5 Partially correct 12 ms 1156 KB Partially correct
6 Partially correct 12 ms 1036 KB Partially correct
7 Partially correct 12 ms 1156 KB Partially correct
8 Partially correct 12 ms 908 KB Partially correct
9 Partially correct 12 ms 1152 KB Partially correct
10 Partially correct 12 ms 1152 KB Partially correct
11 Partially correct 12 ms 1036 KB Partially correct
12 Partially correct 13 ms 1148 KB Partially correct
13 Partially correct 12 ms 1148 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 1148 KB Partially correct
17 Partially correct 12 ms 1148 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 76 ms 2628 KB Partially correct
2 Partially correct 98 ms 2500 KB Partially correct
3 Partially correct 75 ms 2628 KB Partially correct
4 Partially correct 92 ms 2656 KB Partially correct
5 Partially correct 91 ms 2636 KB Partially correct
6 Partially correct 88 ms 2640 KB Partially correct
7 Partially correct 85 ms 2640 KB Partially correct
8 Partially correct 85 ms 2636 KB Partially correct
9 Partially correct 76 ms 2628 KB Partially correct
10 Partially correct 72 ms 2764 KB Partially correct
11 Partially correct 72 ms 2660 KB Partially correct
12 Partially correct 73 ms 2660 KB Partially correct
13 Partially correct 73 ms 2508 KB Partially correct
14 Partially correct 73 ms 2760 KB Partially correct
15 Partially correct 79 ms 2656 KB Partially correct
16 Partially correct 77 ms 2644 KB Partially correct
17 Partially correct 78 ms 2660 KB Partially correct
18 Partially correct 84 ms 2588 KB Partially correct
19 Partially correct 73 ms 2508 KB Partially correct