int mask[930];
bool isActive(int v, int k) { return v & (1 << k); }
int encode (int n, int x, int y)
{
int cnt = 1;
for(int m = 0 ; cnt <= n ; m++)
if( __builtin_popcount( m ) == 6 ) mask[ cnt++ ] = m;
x = mask[ x ];
y = mask[ y ];
for(int j = 0 ; j < 12 ; j++)
if( isActive( x , j ) && !isActive( y , j ) ) return j + 1;
}
int mask[930];
bool isActive(int v, int k) { return v & (1 << k); }
int decode (int n, int q, int h)
{
h--;
int cnt = 1;
for(int m = 0 ; cnt <= n ; m++)
if( __builtin_popcount( m ) == 6 ) mask[ cnt++ ] = m;
if( isActive( mask[ q ] , h ) ) return 1;
return 0;
}
Compilation message
encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:17:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
7025 ms |
9020 KB |
Time limit exceeded |
2 |
Execution timed out |
7100 ms |
9140 KB |
Time limit exceeded |