답안 #200031

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
200031 2020-02-05T01:02:31 Z combi1k1 Xylophone (JOI18_xylophone) C++14
100 / 100
102 ms 556 KB
#include "xylophone.h"
#include<bits/stdc++.h>

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<int,int>   ii;

int a[N];
int d[N][2];

void solve(int n)   {
    d[2][0] = query(1,2);

    for(int i = 3 ; i <= n ; ++i)   {
        d[i][0] = query(i - 1,i);
        d[i][1] = query(i - 2,i);
    }
    a[2] = d[2][0];

    for(int i = 3 ; i <= n ; ++i)   {
        if (d[i][1] == d[i][0] + d[i - 1][0])   {
            if (a[i - 2] < a[i - 1])
                a[i] = a[i - 1] + d[i][0];
            else
                a[i] = a[i - 1] - d[i][0];
        }
        else    {
            if (a[i - 2] < a[i - 1])
                a[i] = a[i - 1] - d[i][0];
            else
                a[i] = a[i - 1] + d[i][0];
        }
    }
    int mn =  N;
    int mx = -N;

    for(int i = 1 ; i <= n ; ++i)   {
        if (mx < a[i])  mx = a[i];
        if (mn > a[i])  mn = a[i];
    }
    int cof = -mn + 1;
    int inv = 1;

    for(int i = 1 ; i <= n ; ++i)   {
        if (a[i] == mn) break;
        if (a[i] == mx) {
            inv = -1;
            cof = mx + 1;
            break;
        }
    }
    for(int i = 1 ; i <= n ; ++i)
        answer(i,inv * a[i] + cof);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 248 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 7 ms 248 KB Output is correct
6 Correct 7 ms 376 KB Output is correct
7 Correct 7 ms 248 KB Output is correct
8 Correct 6 ms 248 KB Output is correct
9 Correct 7 ms 376 KB Output is correct
10 Correct 7 ms 248 KB Output is correct
11 Correct 7 ms 248 KB Output is correct
12 Correct 7 ms 248 KB Output is correct
13 Correct 7 ms 380 KB Output is correct
14 Correct 6 ms 512 KB Output is correct
15 Correct 7 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 248 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 7 ms 248 KB Output is correct
6 Correct 7 ms 376 KB Output is correct
7 Correct 7 ms 248 KB Output is correct
8 Correct 6 ms 248 KB Output is correct
9 Correct 7 ms 376 KB Output is correct
10 Correct 7 ms 248 KB Output is correct
11 Correct 7 ms 248 KB Output is correct
12 Correct 7 ms 248 KB Output is correct
13 Correct 7 ms 380 KB Output is correct
14 Correct 6 ms 512 KB Output is correct
15 Correct 7 ms 248 KB Output is correct
16 Correct 9 ms 248 KB Output is correct
17 Correct 12 ms 448 KB Output is correct
18 Correct 19 ms 248 KB Output is correct
19 Correct 24 ms 336 KB Output is correct
20 Correct 25 ms 248 KB Output is correct
21 Correct 25 ms 376 KB Output is correct
22 Correct 25 ms 248 KB Output is correct
23 Correct 22 ms 248 KB Output is correct
24 Correct 22 ms 252 KB Output is correct
25 Correct 26 ms 248 KB Output is correct
26 Correct 23 ms 376 KB Output is correct
27 Correct 19 ms 252 KB Output is correct
28 Correct 22 ms 248 KB Output is correct
29 Correct 23 ms 376 KB Output is correct
30 Correct 23 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 248 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 7 ms 248 KB Output is correct
6 Correct 7 ms 376 KB Output is correct
7 Correct 7 ms 248 KB Output is correct
8 Correct 6 ms 248 KB Output is correct
9 Correct 7 ms 376 KB Output is correct
10 Correct 7 ms 248 KB Output is correct
11 Correct 7 ms 248 KB Output is correct
12 Correct 7 ms 248 KB Output is correct
13 Correct 7 ms 380 KB Output is correct
14 Correct 6 ms 512 KB Output is correct
15 Correct 7 ms 248 KB Output is correct
16 Correct 9 ms 248 KB Output is correct
17 Correct 12 ms 448 KB Output is correct
18 Correct 19 ms 248 KB Output is correct
19 Correct 24 ms 336 KB Output is correct
20 Correct 25 ms 248 KB Output is correct
21 Correct 25 ms 376 KB Output is correct
22 Correct 25 ms 248 KB Output is correct
23 Correct 22 ms 248 KB Output is correct
24 Correct 22 ms 252 KB Output is correct
25 Correct 26 ms 248 KB Output is correct
26 Correct 23 ms 376 KB Output is correct
27 Correct 19 ms 252 KB Output is correct
28 Correct 22 ms 248 KB Output is correct
29 Correct 23 ms 376 KB Output is correct
30 Correct 23 ms 248 KB Output is correct
31 Correct 42 ms 376 KB Output is correct
32 Correct 55 ms 328 KB Output is correct
33 Correct 79 ms 376 KB Output is correct
34 Correct 94 ms 376 KB Output is correct
35 Correct 90 ms 376 KB Output is correct
36 Correct 98 ms 356 KB Output is correct
37 Correct 94 ms 376 KB Output is correct
38 Correct 102 ms 376 KB Output is correct
39 Correct 81 ms 376 KB Output is correct
40 Correct 99 ms 380 KB Output is correct
41 Correct 96 ms 376 KB Output is correct
42 Correct 92 ms 376 KB Output is correct
43 Correct 97 ms 376 KB Output is correct
44 Correct 93 ms 380 KB Output is correct
45 Correct 90 ms 376 KB Output is correct
46 Correct 92 ms 376 KB Output is correct
47 Correct 96 ms 376 KB Output is correct
48 Correct 86 ms 384 KB Output is correct
49 Correct 85 ms 376 KB Output is correct
50 Correct 96 ms 376 KB Output is correct
51 Correct 101 ms 504 KB Output is correct
52 Correct 90 ms 376 KB Output is correct
53 Correct 92 ms 376 KB Output is correct
54 Correct 81 ms 376 KB Output is correct
55 Correct 93 ms 556 KB Output is correct
56 Correct 86 ms 376 KB Output is correct
57 Correct 84 ms 376 KB Output is correct
58 Correct 84 ms 376 KB Output is correct
59 Correct 91 ms 376 KB Output is correct
60 Correct 92 ms 376 KB Output is correct