Submission #535553

# Submission time Handle Problem Language Result Execution time Memory
535553 2022-03-10T13:33:15 Z Deepesson Data Transfer (IOI19_transfer) C++17
88 / 100
153 ms 2500 KB
#include <bits/stdc++.h>
#include "transfer.h"

std::vector<int> get_attachment(std::vector<int> source) {
    int xoro=0;
    int count=0;
  ///  std::cout<<"Get: "<<source.size()<<"\n";
    std::vector<int> g;
    for(int i=0;i!=source.size();++i){
        if(source[i]){xoro^=i+1;++count;}
    }
    g.push_back(count&1);
    for(int i=0;i!=8;++i){
        if(xoro&(1<<i))g.push_back(1);else g.push_back(0);
    }
  ///  std::cout<<"Send: "<<g.size()<<"\n";
    return g;
}

std::vector<int> retrieve(std::vector<int> data) {
   /// std::cout<<"Size: "<<data.size()<<"\n";
    std::vector<int> primario,ajuda;
    for(int i=0;i!=data.size()-9;++i){
        primario.push_back(data[i]);
    }
    for(int i=data.size()-9;i!=data.size();++i){
        ajuda.push_back(data[i]);
    }
    int xoresperado=0,countesperado=ajuda[0];
    for(int i=1;i!=ajuda.size();++i){
        if(ajuda[i])xoresperado+=(1<<(i-1));
    }
    int xoro=0,count=0;
    for(int i=0;i!=primario.size();++i){
        if(primario[i]){xoro^=i+1;++count;}
    }
    bool check1=xoro==xoresperado;
    bool check2=(count&1)==(countesperado&1);
    ///Os dois checks estao corretos. O array eh igual.
    if(check1&&check2){
        return primario;
    }
    ///Os checks estao dando resultados distintos: um dos checks esta corrompido\
    ///Significa que o array esta intacto :p
    if(check1!=check2){
        return primario;
    }
    ///Se chegou aq eh pq o array esta errado
    int falta = xoresperado^xoro;
    primario[falta-1]=!primario[falta-1];
    return primario;
}

Compilation message

transfer.cpp:43:5: warning: multi-line comment [-Wcomment]
   43 |     ///Os checks estao dando resultados distintos: um dos checks esta corrompido\
      |     ^
transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:9:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=0;i!=source.size();++i){
      |                 ~^~~~~~~~~~~~~~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:23:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i=0;i!=data.size()-9;++i){
      |                 ~^~~~~~~~~~~~~~~
transfer.cpp:26:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i=data.size()-9;i!=data.size();++i){
      |                             ~^~~~~~~~~~~~~
transfer.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i=1;i!=ajuda.size();++i){
      |                 ~^~~~~~~~~~~~~~
transfer.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int i=0;i!=primario.size();++i){
      |                 ~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 5 ms 652 KB Partially correct
2 Partially correct 5 ms 644 KB Partially correct
3 Partially correct 6 ms 652 KB Partially correct
4 Partially correct 6 ms 644 KB Partially correct
5 Partially correct 5 ms 652 KB Partially correct
6 Partially correct 7 ms 644 KB Partially correct
7 Partially correct 7 ms 652 KB Partially correct
8 Partially correct 5 ms 828 KB Partially correct
9 Partially correct 5 ms 736 KB Partially correct
10 Partially correct 4 ms 736 KB Partially correct
11 Partially correct 5 ms 804 KB Partially correct
12 Partially correct 5 ms 816 KB Partially correct
13 Partially correct 5 ms 652 KB Partially correct
14 Partially correct 5 ms 652 KB Partially correct
15 Partially correct 5 ms 736 KB Partially correct
16 Partially correct 5 ms 728 KB Partially correct
17 Partially correct 6 ms 732 KB Partially correct
# Verdict Execution time Memory Grader output
1 Correct 132 ms 2492 KB Output is correct
2 Correct 117 ms 2464 KB Output is correct
3 Correct 127 ms 2492 KB Output is correct
4 Correct 141 ms 2500 KB Output is correct
5 Correct 144 ms 2500 KB Output is correct
6 Correct 131 ms 2496 KB Output is correct
7 Correct 129 ms 2500 KB Output is correct
8 Correct 135 ms 2468 KB Output is correct
9 Correct 153 ms 2500 KB Output is correct
10 Correct 119 ms 2500 KB Output is correct
11 Correct 134 ms 2468 KB Output is correct
12 Correct 140 ms 2500 KB Output is correct
13 Correct 126 ms 2496 KB Output is correct
14 Correct 122 ms 2488 KB Output is correct
15 Correct 131 ms 2452 KB Output is correct
16 Correct 151 ms 2500 KB Output is correct
17 Correct 122 ms 2500 KB Output is correct
18 Correct 122 ms 2492 KB Output is correct
19 Correct 130 ms 2500 KB Output is correct