Submission #900287

# Submission time Handle Problem Language Result Execution time Memory
900287 2024-01-08T04:09:51 Z ar88lo Parrots (IOI11_parrots) C++14
0 / 100
4 ms 1340 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;
}

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;
        for(int i = 0; i <v.size(); i+=2){
                int times = v[i]*2+v[i+1];
                ind++;

        }
        for(int i = 0; i <v.size(); i+=2){
                int times = v[i]*2+v[i+1];
                for(int i = 0; i < times; i++)
                        send(ind);
                ind++;

        }
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>

using namespace std;
int vectoint(vector<int> a){
        reverse(a.begin(), a.end());
        int ret = 0;
        for(int i = 0; i < a.size(); i++){
                ret += (a[i]<<i);
        }
        return ret;
}
void decode(int N, int L, int X[]){

    int c[256];
    memset(c, 0, sizeof c);
    for(int i = 0; i < L; i++){
        c[X[i]]++;
    }

    vector<int> ans;
    for(int i = 0; i < N * 8; i++) ans.push_back(0);


    for(int i = 0; i < 256; i++){

        if(c[i] == 1){
            ans[i*2] = 0;
            ans[i*2 + 1] = 1;
        }
        else if(c[i] == 2){
            ans[i*2] = 1;
            ans[i*2+1] = 0;
        }
        else if(c[i] == 3){
            ans[i*2] = 1;
            ans[i*2+1] = 1;
        }
    }
    for(int i = 0; i < ans.size(); i++){
    }
    vector<int> temp;
    for(int i = 0; i < ans.size(); i+=8){
            temp.clear();
            for(int j = i; j < i+8; j++){
                    temp.push_back(ans[j]);
            }
            output(vectoint(temp));
    }

}

Compilation message

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

decoder.cpp: In function 'int vectoint(std::vector<int>)':
decoder.cpp:9:26: 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 < a.size(); i++){
      |                        ~~^~~~~~~~~~
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i = 0; i < ans.size(); i++){
      |                    ~~^~~~~~~~~~~~
decoder.cpp:44:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int i = 0; i < ans.size(); i+=8){
      |                    ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1300 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 784 KB Error : Encoded message too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 796 KB Error : Encoded message too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 796 KB Error : Encoded message too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1316 KB Execution killed with signal 6
2 Runtime error 4 ms 1340 KB Execution killed with signal 6
3 Incorrect 0 ms 796 KB Error : Bad encoded integer
4 Incorrect 1 ms 784 KB Error : Bad encoded integer
5 Incorrect 1 ms 960 KB Error : Bad encoded integer
6 Incorrect 1 ms 784 KB Error : Bad encoded integer
7 Incorrect 0 ms 784 KB Error : Bad encoded integer