#include "xylophone.h"
#include <bits/stdc++.h>
const int NN = 5e3 + 7;
int b[NN];
int get( int x , int y , int x1 , int y1 )
{
if( x1 > y1 ){
if( y == x1 - y1 )return x1 - x;
if( x == y )return x1 - x;
return x1 + x;
}else{
if( y == x + y1 - x1 )return x1 - x;
if( y == y1 - x1 )return x1 + x;
return x1 + x;
}
}
void solve(int n)
{
int i = 1 , j = n;
int l = i , r = n;
while( l < r ){
int m = (l + r) / 2;
if( query( m + 1 , n ) != n - 1 )r = m;
else l = m + 1;
}
i = l;
l = i + 1 , r = n;
while( l < r ){
int m = (l + r) / 2;
if( query( i , m ) != n - 1 )l = m + 1;
else r = m;
}
j = l;
b[i] = 1;
b[j] = n;
if( i != 1 )b[i - 1] = query( i - 1 , i ) + 1;
if( i + 1 < j )b[i + 1] = query( i , i + 1 ) + 1;
if( j - 1 > i + 1 )b[j - 1] = n - query( j - 1 , j );
if( j != n )b[j + 1] = n - query( j , j + 1 );
for( int h = i - 2; h >= 1; h-- ){
int x = query( h , h + 1 );
int y = query( h , h + 2 );
b[h] = get( x , y , b[h + 1] , b[h + 2] );
}
for( int h = i + 2; h <= j - 2; h++ ){
int x = query( h - 1 , h );
int y = query( h - 2 , h );
b[h] = get( x , y , b[h - 1] , b[h - 2] );
}
for( int h = j + 2; h <= n; h++ ){
int x = query( h - 1 , h );
int y = query( h - 2 , h );
b[h] = get( x , y , b[h - 1] , b[h - 2] );
}
for( int h = 1; h <= n; h++ ){
answer( h , b[h] );
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
5 |
Correct |
7 ms |
256 KB |
Output is correct |
6 |
Correct |
6 ms |
256 KB |
Output is correct |
7 |
Correct |
7 ms |
256 KB |
Output is correct |
8 |
Correct |
8 ms |
256 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
7 ms |
256 KB |
Output is correct |
11 |
Correct |
7 ms |
384 KB |
Output is correct |
12 |
Correct |
7 ms |
256 KB |
Output is correct |
13 |
Correct |
7 ms |
256 KB |
Output is correct |
14 |
Correct |
7 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
5 |
Correct |
7 ms |
256 KB |
Output is correct |
6 |
Correct |
6 ms |
256 KB |
Output is correct |
7 |
Correct |
7 ms |
256 KB |
Output is correct |
8 |
Correct |
8 ms |
256 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
7 ms |
256 KB |
Output is correct |
11 |
Correct |
7 ms |
384 KB |
Output is correct |
12 |
Correct |
7 ms |
256 KB |
Output is correct |
13 |
Correct |
7 ms |
256 KB |
Output is correct |
14 |
Correct |
7 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
384 KB |
Output is correct |
16 |
Correct |
10 ms |
256 KB |
Output is correct |
17 |
Correct |
13 ms |
384 KB |
Output is correct |
18 |
Correct |
23 ms |
376 KB |
Output is correct |
19 |
Correct |
20 ms |
256 KB |
Output is correct |
20 |
Correct |
24 ms |
376 KB |
Output is correct |
21 |
Correct |
14 ms |
376 KB |
Output is correct |
22 |
Correct |
31 ms |
384 KB |
Output is correct |
23 |
Correct |
31 ms |
376 KB |
Output is correct |
24 |
Correct |
27 ms |
384 KB |
Output is correct |
25 |
Correct |
28 ms |
256 KB |
Output is correct |
26 |
Correct |
21 ms |
384 KB |
Output is correct |
27 |
Correct |
24 ms |
376 KB |
Output is correct |
28 |
Correct |
27 ms |
384 KB |
Output is correct |
29 |
Correct |
32 ms |
256 KB |
Output is correct |
30 |
Correct |
23 ms |
380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
5 |
Correct |
7 ms |
256 KB |
Output is correct |
6 |
Correct |
6 ms |
256 KB |
Output is correct |
7 |
Correct |
7 ms |
256 KB |
Output is correct |
8 |
Correct |
8 ms |
256 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
7 ms |
256 KB |
Output is correct |
11 |
Correct |
7 ms |
384 KB |
Output is correct |
12 |
Correct |
7 ms |
256 KB |
Output is correct |
13 |
Correct |
7 ms |
256 KB |
Output is correct |
14 |
Correct |
7 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
384 KB |
Output is correct |
16 |
Correct |
10 ms |
256 KB |
Output is correct |
17 |
Correct |
13 ms |
384 KB |
Output is correct |
18 |
Correct |
23 ms |
376 KB |
Output is correct |
19 |
Correct |
20 ms |
256 KB |
Output is correct |
20 |
Correct |
24 ms |
376 KB |
Output is correct |
21 |
Correct |
14 ms |
376 KB |
Output is correct |
22 |
Correct |
31 ms |
384 KB |
Output is correct |
23 |
Correct |
31 ms |
376 KB |
Output is correct |
24 |
Correct |
27 ms |
384 KB |
Output is correct |
25 |
Correct |
28 ms |
256 KB |
Output is correct |
26 |
Correct |
21 ms |
384 KB |
Output is correct |
27 |
Correct |
24 ms |
376 KB |
Output is correct |
28 |
Correct |
27 ms |
384 KB |
Output is correct |
29 |
Correct |
32 ms |
256 KB |
Output is correct |
30 |
Correct |
23 ms |
380 KB |
Output is correct |
31 |
Correct |
44 ms |
376 KB |
Output is correct |
32 |
Correct |
85 ms |
352 KB |
Output is correct |
33 |
Correct |
75 ms |
504 KB |
Output is correct |
34 |
Incorrect |
72 ms |
384 KB |
Wrong Answer [2] |
35 |
Halted |
0 ms |
0 KB |
- |