Submission #820680

# Submission time Handle Problem Language Result Execution time Memory
820680 2023-08-11T05:26:55 Z dashka Question (Grader is different from the original contest) (CEOI14_question_grader) C++14
100 / 100
2544 ms 24416 KB
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
 
vector<vector<int> > v;
bool voltemar;
 
int encode (int n, int x, int y) {
    if(!voltemar) {
        voltemar = true;
        v.pb({});
        vector<int> subset = {0, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0};
        for(int i = 0; i < 924; i++) {
            v.pb(subset);
            // v.pb({42});
            /*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;
                }
            }*/
            next_permutation(subset.begin(), subset.end());
        }
    }
    for(int i = 1; i <= 12; i++) {
        if(v[x][i] == -1 && v[y][i] == 0) {
            return i;
        }
    }
    return -1;
}
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
 
vector<vector<int> > w;
bool woltemar;
 
int decode (int n, int q, int h) {
	if(!woltemar) {
		woltemar = true;
		w.pb({});
		vector<int> subset = {0, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0};
		for(int i = 0; i < 924; i++) {
			w.pb(subset);
			/*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;
				}
			}*/
			next_permutation(subset.begin(), subset.end());
		}
	}
	return ((w[q][h] == -1) ? 1 : 0);
}
# Verdict Execution time Memory Grader output
1 Correct 2544 ms 24352 KB Output is correct - maxh = 12
2 Correct 2526 ms 24416 KB Output is correct - maxh = 12