답안 #359316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
359316 2021-01-26T18:14:22 Z shahriarkhan Xylophone (JOI18_xylophone) C++14
100 / 100
84 ms 496 KB
#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std ;

void solve(int N) {

	int A[N+2] = {0} , vis[N+2] = {0} , low = 1 , high = N ;
    while(low<high)
    {
        int mid = (low+high+1)>>1 ;
        if(query(mid,N)==(N-1)) low = mid ;
        else high = mid - 1 ;
    }
    A[low] = 1 , vis[1] = 1 ;
    for(int i = low - 1 ; i >= 1 ; --i)
    {
        int temp = query(i,i+1) , left = A[i+1] - temp , right = A[i+1] + temp ;
        if((left<=0) || vis[left])
        {
            vis[right] = 1 ;
            A[i] = right ;
        }
        else if((right>N) || vis[right])
        {
            vis[left] = 1 ;
            A[i] = left ;
        }
        else
        {
            temp = query(i,i+2) ;
            if((max(right,A[i+2])-min(A[i+1],A[i+2]))==temp)
            {
                vis[right] = 1 ;
                A[i] = right ;
            }
            else
            {
                vis[left] = 1 ;
                A[i] = left ;
            }
        }
    }
    for(int i = low + 1 ; i <= N ; ++i)
    {
        int temp = query(i-1,i) , left = A[i-1] - temp , right = A[i-1] + temp ;
        if((left<=0) || vis[left])
        {
            vis[right] = 1 ;
            A[i] = right ;
        }
        else if((right>N) || vis[right])
        {
            vis[left] = 1 ;
            A[i] = left ;
        }
        else
        {
            temp = query(i-2,i) ;
            if((max(right,A[i-2])-min(A[i-1],A[i-2]))==temp)
            {
                vis[right] = 1 ;
                A[i] = right ;
            }
            else
            {
                vis[left] = 1 ;
                A[i] = left ;
            }
        }
    }
	for(int i = 1; i <= N; i++)
    {
		answer(i, A[i]) ;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 3 ms 364 KB Output is correct
17 Correct 6 ms 364 KB Output is correct
18 Correct 10 ms 364 KB Output is correct
19 Correct 14 ms 364 KB Output is correct
20 Correct 13 ms 364 KB Output is correct
21 Correct 15 ms 404 KB Output is correct
22 Correct 15 ms 364 KB Output is correct
23 Correct 10 ms 364 KB Output is correct
24 Correct 12 ms 364 KB Output is correct
25 Correct 9 ms 364 KB Output is correct
26 Correct 12 ms 492 KB Output is correct
27 Correct 14 ms 364 KB Output is correct
28 Correct 13 ms 492 KB Output is correct
29 Correct 14 ms 364 KB Output is correct
30 Correct 13 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 2 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 3 ms 364 KB Output is correct
17 Correct 6 ms 364 KB Output is correct
18 Correct 10 ms 364 KB Output is correct
19 Correct 14 ms 364 KB Output is correct
20 Correct 13 ms 364 KB Output is correct
21 Correct 15 ms 404 KB Output is correct
22 Correct 15 ms 364 KB Output is correct
23 Correct 10 ms 364 KB Output is correct
24 Correct 12 ms 364 KB Output is correct
25 Correct 9 ms 364 KB Output is correct
26 Correct 12 ms 492 KB Output is correct
27 Correct 14 ms 364 KB Output is correct
28 Correct 13 ms 492 KB Output is correct
29 Correct 14 ms 364 KB Output is correct
30 Correct 13 ms 364 KB Output is correct
31 Correct 26 ms 364 KB Output is correct
32 Correct 35 ms 364 KB Output is correct
33 Correct 53 ms 364 KB Output is correct
34 Correct 56 ms 412 KB Output is correct
35 Correct 56 ms 364 KB Output is correct
36 Correct 53 ms 384 KB Output is correct
37 Correct 27 ms 412 KB Output is correct
38 Correct 43 ms 492 KB Output is correct
39 Correct 82 ms 364 KB Output is correct
40 Correct 60 ms 492 KB Output is correct
41 Correct 48 ms 364 KB Output is correct
42 Correct 55 ms 492 KB Output is correct
43 Correct 56 ms 364 KB Output is correct
44 Correct 41 ms 372 KB Output is correct
45 Correct 84 ms 364 KB Output is correct
46 Correct 60 ms 364 KB Output is correct
47 Correct 79 ms 492 KB Output is correct
48 Correct 59 ms 364 KB Output is correct
49 Correct 64 ms 492 KB Output is correct
50 Correct 78 ms 364 KB Output is correct
51 Correct 50 ms 492 KB Output is correct
52 Correct 55 ms 364 KB Output is correct
53 Correct 49 ms 492 KB Output is correct
54 Correct 55 ms 364 KB Output is correct
55 Correct 63 ms 364 KB Output is correct
56 Correct 56 ms 364 KB Output is correct
57 Correct 62 ms 364 KB Output is correct
58 Correct 68 ms 496 KB Output is correct
59 Correct 63 ms 364 KB Output is correct
60 Correct 63 ms 364 KB Output is correct