Submission #500665

#TimeUsernameProblemLanguageResultExecution timeMemory
500665aryan12Parrots (IOI11_parrots)C++17
88 / 100
9 ms1356 KiB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> base4conv(int x) {
    int lmao = 64;
    vector<int> ans;
    while(lmao != 0) {
        int ok = x / lmao;
        x -= ok * lmao;
        ans.push_back(ok);
        lmao /= 4;
    }
    return ans;
}

void encode(int N, int M[]) {
    if(N <= 32) {
        for(int i = 0; i < N; i++) {
            vector<int> pos1;
            int cnt1 = 0;
            for(int j = 0; j < 9; j++) {
                if((1 << j) & M[i]) {
                    cnt1++;
                    pos1.push_back(j);
                }
            }
            int sent_num = 0;
            sent_num += (8 * i); 
            for(int j = 0; j < pos1.size(); j++) {
                send(sent_num + pos1[j]);
            }
        }
    }
    else {
        for(int i = 0; i < N; i++) {
            vector<int> cur = base4conv(M[i]);
            for(int j = 0; j < cur.size(); j++) {
                for(int k = 0; k < cur[j]; k++) {
                   // cout << "i = " << i << ", j = " << j << ", val = " << i * 4 + j << "\n";
                    send(i * 4 + j);
                }
            }
        }
    }
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>
using namespace std;

void decode(int N, int L, int X[]) {
    if(N <= 32) {
        vector<int> one_bits[N];
        for(int i = 0; i < L; i++) {
            int cur_num = X[i];
            int pos = cur_num / 8;
            cur_num %= 8;
            one_bits[pos].push_back(cur_num);
        }
        for(int i = 0; i < N; i++) {
            int ans = 0;
            for(int j = 0; j < one_bits[i].size(); j++) {
                ans += (1 << one_bits[i][j]);
            }
            output(ans);
        }
    }
    else {
        int check[256] = {0};
        for(int i = 0; i < L; i++) {
            check[X[i]]++;
        }
        for(int i = 0; i < N * 4; i += 4) {
            int ok = 64, ans = 0;
            for(int j = 0; j < 4; j++) {
                int idx = i + j;
                ans += (ok * check[idx]);
                ok /= 4;
            }
            output(ans);
        }
    }
}

Compilation message (stderr)

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:31:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             for(int j = 0; j < pos1.size(); j++) {
      |                            ~~^~~~~~~~~~~~~
encoder.cpp:39:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             for(int j = 0; j < cur.size(); j++) {
      |                            ~~^~~~~~~~~~~~

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:17:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |             for(int j = 0; j < one_bits[i].size(); j++) {
      |                            ~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...