Submission #146933

#TimeUsernameProblemLanguageResultExecution timeMemory
146933popovicirobertParrots (IOI11_parrots)C++14
98 / 100
14 ms2032 KiB
#include "encoder.h"
#include "encoderlib.h"
#include <bits/stdc++.h>

using namespace std;

static vector < vector <int> > arr;

static void bfs() {
    vector < vector <int> > Q;
    int beg = 0;
    for(int i = 0; i < 4; i++) {
        Q.push_back({i});
    }
    while(1) {
        vector <int> cur = Q[beg++];
        arr.push_back(cur);
        if(arr.size() >= 256) {
            break;
        }
        for(int i = 0; i < 4; i++) {
            if(cur.back() <= i) {
                vector <int> aux = cur;
                aux.push_back(i);
                Q.push_back(aux);
            }
        }
    }
}

void encode(int n, int M[]) {
    bfs();
    for(int i = 0; i < n; i++) {
        int cur = (i << 2);
        for(auto it : arr[M[i]]) {
            send(it + cur);
        }
    }
}
#include "decoder.h"
#include "decoderlib.h"
#include <bits/stdc++.h>

using namespace std;

static vector < vector <int> > arr;

static void bfs() {
    vector < vector <int> > Q;
    int beg = 0;
    for(int i = 0; i < 4; i++) {
        Q.push_back({i});
    }
    while(1) {
        vector <int> cur = Q[beg++];
        arr.push_back(cur);
        if(arr.size() >= 256) {
            break;
        }
        for(int i = 0; i < 4; i++) {
            if(cur.back() <= i) {
                vector <int> aux = cur;
                aux.push_back(i);
                Q.push_back(aux);
            }
        }
    }
}

void decode(int n, int l, int X[]) {
    bfs();
    vector < vector <int> > pos(n);
    for(int i = 0; i < l; i++) {
        pos[X[i] >> 2].push_back(X[i] & 3);
    }
    for(int i = 0; i < n; i++) {
        sort(pos[i].begin(), pos[i].end());
        for(int j = 0; j < arr.size(); j++) {
            if(arr[j] == pos[i]) {
                output(j);
                break;
            }
        }
    }
}

Compilation message (stderr)

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:39:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0; j < arr.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...