#include<bits/stdc++.h>
#define ll long long
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define endl '\n'
#define pb push_back
using namespace std ;
//fflush(stdout) ;
int a[13][940] ;
int bits_co(int x){
int ans=0 ;
for(int i=0 ; i<12 ; i++){
if(x&(1<<i)) ans++ ;
}
return ans ;
}
void make(){
int r=1 ;
for(int i=1 ; i<(1<<12) ; i++){
if(bits_co(i)==6){
for(int j=0 ; j<12 ; j++){
if(i&(1<<j)) a[j][r]=1 ;
else a[j][r]=0 ;
}
r++ ;
}
}
}
int encode (int n, int x, int y) {
if(a[0][1]==0) make() ;
for(int i=0 ; i<12 ; i++){
if(a[i][x]==1&&a[i][y]==0) return i+1 ;
}
return 1 ;
}
#include<bits/stdc++.h>
#define ll long long
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define endl '\n'
#define pb push_back
using namespace std ;
//fflush(stdout) ;
int a[13][940] ;
int bits_co(int x){
int ans=0 ;
for(int i=0 ; i<12 ; i++){
if(x&(1<<i)) ans++ ;
}
return ans ;
}
void make(){
int r=1 ;
for(int i=1 ; i<(1<<12) ; i++){
if(bits_co(i)==6){
for(int j=0 ; j<12 ; j++){
if(i&(1<<j)) a[j][r]=1 ;
else a[j][r]=0 ;
}
r++ ;
}
}
}
int decode (int n, int q, int h) {
if(a[0][1]==0) make() ;
h-- ;
return a[h][q] ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3074 ms |
24276 KB |
Output is correct - maxh = 12 |
2 |
Correct |
3090 ms |
24088 KB |
Output is correct - maxh = 12 |