Submission #132882

# Submission time Handle Problem Language Result Execution time Memory
132882 2019-07-19T21:29:21 Z Osama_Alkhodairy Question (Grader is different from the original contest) (CEOI14_question_grader) C++17
100 / 100
1616 ms 79768 KB
#include <bits/stdc++.h>
using namespace std;

vector <vector <int> > all;

int encode (int n, int x, int y) {
    x--; y--;
    const int K = 12;
    if(all.size() == 0){
        for(int i = 0 ; i < (1 << K) ; i++){
            if(__builtin_popcount(i) != K / 2) continue;
            vector <int> cur;
            for(int j = 0 ; j < K ; j++){
                if((i >> j) & 1) cur.push_back(j);
            }
            all.push_back(cur);
        }
    }
    for(auto &i : all[x]){
        if(count(all[y].begin(), all[y].end(), i)) continue;
        return i + 1;
    }
    assert(false);
}
#include <bits/stdc++.h>
using namespace std;

vector <vector <int> > all;

int decode (int n, int q, int h) {
    h--; q--;
    const int K = 12;
    if(all.size() == 0){
        for(int i = 0 ; i < (1 << K) ; i++){
            if(__builtin_popcount(i) != K / 2) continue;
            vector <int> cur;
            for(int j = 0 ; j < K ; j++){
                if((i >> j) & 1) cur.push_back(j);
            }
            all.push_back(cur);
        }
    }
    for(auto &i : all[q]){
        if(i == h) return 1;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1616 ms 79416 KB Output is correct - maxh = 12
2 Correct 1611 ms 79768 KB Output is correct - maxh = 12