Submission #113686

# Submission time Handle Problem Language Result Execution time Memory
113686 2019-05-27T18:23:09 Z rajarshi_basu Question (Grader is different from the original contest) (CEOI14_question_grader) C++14
100 / 100
1361 ms 78608 KB
#include <iostream>
#include <vector>
#include <set>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <complex>
#include <stack>
#include <set>

#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define cd complex<double> 
#define ld long double
#define pld pair<ld,ld>
#define iii pair<ii,int>

const ld INF = 1e9+10;
using namespace std;
const int MAXN = 1000*100*2+10;
const int MAXVAL = 1e9+10;

const int N = 1000;
int mp[N];
void precalc(){
	int ptr = 0;
	FOR(mask,1<<12){
		int ctr = 0;
		FOR(i,12){
			if((mask&(1<<i))>0)ctr++;
		}
		if(ctr == 6){
			mp[ptr] = mask;
			ptr++;
		}
	}
}

#define endl '\n'

int encode(int n,int a,int b){
  if(mp[0] == 0)precalc();
  int ptr = 0;
			while(1){
				if((mp[a]&(1<<ptr))>0){
					if((mp[b]&(1<<ptr)) == 0){
						break;
					}
				}
				ptr++;
			}
			//cout << ptr+1 << endl;
  return ptr+1;
}

#include <iostream>
#include <vector>
#include <set>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <complex>
#include <stack>
#include <set>

#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define cd complex<double> 
#define ld long double
#define pld pair<ld,ld>
#define iii pair<ii,int>

const ld INF = 1e9+10;
using namespace std;
const int MAXN = 1000*100*2+10;
const int MAXVAL = 1e9+10;

const int N = 1000;
int mp[N];
void precalc(){
	int ptr = 0;
	FOR(mask,1<<12){
		int ctr = 0;
		FOR(i,12){
			if((mask&(1<<i))>0)ctr++;
		}
		if(ctr == 6){
			mp[ptr] = mask;
			ptr++;
		}
	}
}

int decode(int n,int q,int h){
  if(mp[0] == 0)precalc();
	h--;
			if(mp[q]&(1<<h)){
              return 1;
				//cout << "yes" << endl;
			}else{
              return 0;
				//cout << "no" << endl;
			}
}
# Verdict Execution time Memory Grader output
1 Correct 1361 ms 78608 KB Output is correct - maxh = 12
2 Correct 1318 ms 78536 KB Output is correct - maxh = 12