Submission #900294

# Submission time Handle Problem Language Result Execution time Memory
900294 2024-01-08T04:27:29 Z ar88lo Parrots (IOI11_parrots) C++14
Compilation error
0 ms 0 KB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> tovec(int a){
    vector<int> ret;
    for(int i = 0; i < 8; i++){
            ret.push_back(a%2);
            a/=2;
    }

    return ret;
}
int b [] = {3, 2, 1};
void encode(int N, int M[]){

    vector<int> v;
    for(int i = N-1; i >= 0; i--){
            vector<int> temp = tovec(M[i]);
            for(auto t:temp){
                    v.push_back(t);
            }
    }
    reverse(v.begin(), v.end());
    int ind = 0;
    int times = 0;
    for(int i = 0; i <v.size(); i+=2){
            if(v[i] == 1 && v[i+1] == 1){
                    times++;
            }

    }
    if(times > 6*N){
         send(0); send(0); send(0); send(0);
      		reverse(b, b+3);
    }
    for(int i = 0; i <v.size(); i+=2){
            if(v[i] == 1 && v[i+1] == 1){
                    for(int i = 0; i < b[0]; i++){
                      send(ind);
                    }
            }
            if(v[i] == 1 && v[i+1] == 0){
                    for(int i = 0; i < b[1]; i++){
                      send(ind);
                    }
            }
            if(v[i] == 0 && v[i+1] == 1){
                    for(int i= 0; i < b[2]; i++){
                      send(ind);
                    }
            }
            ind++;

    }
}



    

Compilation message

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i = 0; i <v.size(); i+=2){
      |                    ~~^~~~~~~~~
encoder.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i = 0; i <v.size(); i+=2){
      |                    ~~^~~~~~~~~

/usr/bin/ld: /tmp/ccNCMgOM.o: in function `main':
grader_decoder.cpp:(.text.startup+0x1ef): undefined reference to `decode(int, int, int*)'
collect2: error: ld returned 1 exit status