# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
354402 | rqi | Question (Grader is different from the original contest) (CEOI14_question_grader) | C++14 | 7093 ms | 4204 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ins insert
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
const int maxh = 12;
vector<vi> subs;
vi sub;
void genSub(int curnum = 1){
if(sz(sub) == maxh/2){
subs.pb(sub);
// for(auto u: sub){
// cout << u << " ";
// }
// cout << "\n";
return;
}
for(int i = curnum; i <= maxh; i++){
sub.pb(i);
genSub(i+1);
sub.pop_back();
}
}
int num[1005][1005];
bool pres[1005][maxh+1]; //is this number present in the row?
bool calculated = false;
void precalc(){
if(calculated) return;
calculated = true;
genSub();
for(int i = 0; i < sz(subs); i++){
for(int j = 0; j < sz(subs); j++){
if(i == j) continue;
vector<bool> insub1(maxh+1, 0);
vector<bool> insub2(maxh+1, 1);
for(int k = 0; k < sz(subs[i]); k++){
insub1[subs[i][k]] = 1;
}
for(int k = 0; k < sz(subs[j]); k++){
insub2[subs[j][k]] = 0;
}
for(int h = 1; h <= maxh; h++){
if(insub1[h] && insub2[h]){
num[i][j] = h;
}
}
}
}
// for(int i = 0; i < sz(subs); i++){
// for(int j = 0; j < sz(subs); j++){
// cout << num[i][j] << " ";
// }
// cout << "\n";
// }
for(int i = 0; i < sz(subs); i++){
for(int j = 0; j < sz(subs); j++){
pres[i][num[i][j]] = 1;
}
}
}
int encode (int n, int x, int y) {
precalc();
x--;
y--;
for(int i = 0; i < sz(subs); i++){
for(int j = 0; j < sz(subs); j++){
if(i == j) continue;
vector<bool> insub1(maxh+1, 0);
vector<bool> insub2(maxh+1, 1);
for(int k = 0; k < sz(subs[i]); k++){
insub1[subs[i][k]] = 1;
}
for(int k = 0; k < sz(subs[j]); k++){
insub2[subs[j][k]] = 0;
}
for(int h = 1; h <= maxh; h++){
if(insub1[h] && insub2[h]){
num[i][j] = h;
}
}
}
}
return num[x][y];
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ins insert
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
const int maxh = 12;
vector<vi> subs;
vi sub;
void genSub(int curnum = 1){
if(sz(sub) == maxh/2){
subs.pb(sub);
// for(auto u: sub){
// cout << u << " ";
// }
// cout << "\n";
return;
}
for(int i = curnum; i <= maxh; i++){
sub.pb(i);
genSub(i+1);
sub.pop_back();
}
}
int num[1005][1005];
bool pres[1005][maxh+1]; //is this number present in the row?
bool calculated = false;
void precalc(){
if(calculated) return;
calculated = true;
genSub();
for(int i = 0; i < sz(subs); i++){
for(int j = 0; j < sz(subs); j++){
if(i == j) continue;
vector<bool> insub1(maxh+1, 0);
vector<bool> insub2(maxh+1, 1);
for(int k = 0; k < sz(subs[i]); k++){
insub1[subs[i][k]] = 1;
}
for(int k = 0; k < sz(subs[j]); k++){
insub2[subs[j][k]] = 0;
}
for(int h = 1; h <= maxh; h++){
if(insub1[h] && insub2[h]){
num[i][j] = h;
}
}
}
}
// for(int i = 0; i < sz(subs); i++){
// for(int j = 0; j < sz(subs); j++){
// cout << num[i][j] << " ";
// }
// cout << "\n";
// }
for(int i = 0; i < sz(subs); i++){
for(int j = 0; j < sz(subs); j++){
pres[i][num[i][j]] = 1;
}
}
}
int decode (int n, int q, int h) {
precalc();
q--;
if(pres[q][h]){
return 1;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |