Submission #793878

# Submission time Handle Problem Language Result Execution time Memory
793878 2023-07-26T07:47:48 Z Valaki2 Question (Grader is different from the original contest) (CEOI14_question_grader) C++14
0 / 100
234 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;

#define pb push_back

vector<vector<int> > v;

int encode (int n, int x, int y) {
    v.pb({});
    vector<int> subset = {0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0};
    while(true) {
        v.pb(subset);
        if(subset[7] && subset[8] && subset[9] && subset[10] && subset[11] && subset[12]) {
            break;
        }
        int j = -1, cnt = 0;
        for(int i = 12; i >= 1; i--) {
            if(!subset[i]) {
                j = i;
                break;
            }
            cnt++;
        }
        for(; j >= 1; j--) {
            if(subset[j]) {
                subset[j] = false;
                for(int i = j + 1; i <= j + 1 + cnt; i++) {
                    subset[i] = true;
                }
                for(int i = j + 1 + cnt + 1; i <= 12; i++) {
                    subset[i] = false;
                }
                break;
            }
        }
    }
    for(int i = 1; i <= 12; i++) {
        if(v[x][i] && !v[y][i]) {
            return i;
        }
    }
    return -1;
}
#include <bits/stdc++.h>
using namespace std;

#define pb push_back

#define v w
vector<vector<int> > v;

int decode (int n, int q, int h) {
	v.pb({});
    vector<int> subset = {0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0};
    while(true) {
        v.pb(subset);
        if(subset[7] && subset[8] && subset[9] && subset[10] && subset[11] && subset[12]) {
            break;
        }
        int j = -1, cnt = 0;
        for(int i = 12; i >= 1; i--) {
            if(!subset[i]) {
                j = i;
                break;
            }
            cnt++;
        }
        for(; j >= 1; j--) {
            if(subset[j]) {
                subset[j] = false;
                for(int i = j + 1; i <= j + 1 + cnt; i++) {
                    subset[i] = true;
                }
                for(int i = j + 1 + cnt + 1; i <= 12; i++) {
                    subset[i] = false;
                }
                break;
            }
        }
    }
	return (v[q][h] ? 1 : 0);
}
# Verdict Execution time Memory Grader output
1 Runtime error 234 ms 262144 KB Execution killed with signal 9
2 Runtime error 218 ms 262144 KB Execution killed with signal 9