답안 #63725

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
63725 2018-08-02T14:36:04 Z FLDutchman Xylophone (JOI18_xylophone) C++14
100 / 100
123 ms 716 KB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;

typedef int INT;

#define int long long
#define FOR(i, l, r) for(int i = (l); i < (r); i++)
#define fst first
#define snd second

typedef vector<int> vi;
typedef pair<int, int> ii;

vi A;
void solve(INT N) {
    A.resize(N);
    A[0] = 0;
    A[1] = query(1, 2);

    FOR(i, 2, N){
        int a = query(i, i+1);
        int b = query(i-1, i+1);
        int p1 = A[i-1] + a, p2 = A[i-1] - a;
        if(abs( max(A[i-2], max(p1, A[i-1])) - min(min(A[i-2], A[i-1]), p1) )  == b) A[i] = p1;
        else A[i] = p2;
    }
    //for(int a : A) cout << a << " ";
    //cout << endl;
    ii mi = {1e9, -1}, ma = {-1e9, -1};
    FOR(i, 0, N) mi = min(mi, {A[i], i}), ma = max(ma, {A[i], i});
    //cout << mi.fst << " " << ma.fst << endl;
    //cout << mi.snd << " " << ma.snd << endl;
    if(mi.snd > ma.snd) {
        //cout << "Reversing " << endl;
        for(int &a : A) a = -a;
        mi.fst = -ma.fst;
    }
    //cout << 1 - mi.fst << endl;
    for(int &a : A) a += 1 - mi.fst;
    //for(int a : A) cout << a << " ";
    //cout << endl;
	FOR(i, 0, N){
        //cout << A[i] << " ";
		answer(i+1, A[i]);
	}
   // cout << endl;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 6 ms 344 KB Output is correct
5 Correct 5 ms 420 KB Output is correct
6 Correct 5 ms 420 KB Output is correct
7 Correct 6 ms 476 KB Output is correct
8 Correct 3 ms 476 KB Output is correct
9 Correct 4 ms 496 KB Output is correct
10 Correct 3 ms 496 KB Output is correct
11 Correct 3 ms 496 KB Output is correct
12 Correct 6 ms 496 KB Output is correct
13 Correct 4 ms 496 KB Output is correct
14 Correct 3 ms 496 KB Output is correct
15 Correct 5 ms 496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 6 ms 344 KB Output is correct
5 Correct 5 ms 420 KB Output is correct
6 Correct 5 ms 420 KB Output is correct
7 Correct 6 ms 476 KB Output is correct
8 Correct 3 ms 476 KB Output is correct
9 Correct 4 ms 496 KB Output is correct
10 Correct 3 ms 496 KB Output is correct
11 Correct 3 ms 496 KB Output is correct
12 Correct 6 ms 496 KB Output is correct
13 Correct 4 ms 496 KB Output is correct
14 Correct 3 ms 496 KB Output is correct
15 Correct 5 ms 496 KB Output is correct
16 Correct 6 ms 496 KB Output is correct
17 Correct 12 ms 496 KB Output is correct
18 Correct 24 ms 496 KB Output is correct
19 Correct 25 ms 576 KB Output is correct
20 Correct 20 ms 576 KB Output is correct
21 Correct 19 ms 576 KB Output is correct
22 Correct 26 ms 576 KB Output is correct
23 Correct 23 ms 576 KB Output is correct
24 Correct 24 ms 576 KB Output is correct
25 Correct 21 ms 576 KB Output is correct
26 Correct 18 ms 576 KB Output is correct
27 Correct 12 ms 576 KB Output is correct
28 Correct 18 ms 576 KB Output is correct
29 Correct 21 ms 576 KB Output is correct
30 Correct 19 ms 576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 6 ms 344 KB Output is correct
5 Correct 5 ms 420 KB Output is correct
6 Correct 5 ms 420 KB Output is correct
7 Correct 6 ms 476 KB Output is correct
8 Correct 3 ms 476 KB Output is correct
9 Correct 4 ms 496 KB Output is correct
10 Correct 3 ms 496 KB Output is correct
11 Correct 3 ms 496 KB Output is correct
12 Correct 6 ms 496 KB Output is correct
13 Correct 4 ms 496 KB Output is correct
14 Correct 3 ms 496 KB Output is correct
15 Correct 5 ms 496 KB Output is correct
16 Correct 6 ms 496 KB Output is correct
17 Correct 12 ms 496 KB Output is correct
18 Correct 24 ms 496 KB Output is correct
19 Correct 25 ms 576 KB Output is correct
20 Correct 20 ms 576 KB Output is correct
21 Correct 19 ms 576 KB Output is correct
22 Correct 26 ms 576 KB Output is correct
23 Correct 23 ms 576 KB Output is correct
24 Correct 24 ms 576 KB Output is correct
25 Correct 21 ms 576 KB Output is correct
26 Correct 18 ms 576 KB Output is correct
27 Correct 12 ms 576 KB Output is correct
28 Correct 18 ms 576 KB Output is correct
29 Correct 21 ms 576 KB Output is correct
30 Correct 19 ms 576 KB Output is correct
31 Correct 45 ms 580 KB Output is correct
32 Correct 84 ms 588 KB Output is correct
33 Correct 51 ms 596 KB Output is correct
34 Correct 114 ms 596 KB Output is correct
35 Correct 109 ms 596 KB Output is correct
36 Correct 74 ms 700 KB Output is correct
37 Correct 116 ms 700 KB Output is correct
38 Correct 117 ms 700 KB Output is correct
39 Correct 123 ms 700 KB Output is correct
40 Correct 113 ms 700 KB Output is correct
41 Correct 119 ms 700 KB Output is correct
42 Correct 42 ms 700 KB Output is correct
43 Correct 96 ms 700 KB Output is correct
44 Correct 90 ms 700 KB Output is correct
45 Correct 98 ms 700 KB Output is correct
46 Correct 118 ms 700 KB Output is correct
47 Correct 63 ms 700 KB Output is correct
48 Correct 41 ms 700 KB Output is correct
49 Correct 106 ms 700 KB Output is correct
50 Correct 83 ms 700 KB Output is correct
51 Correct 91 ms 700 KB Output is correct
52 Correct 99 ms 700 KB Output is correct
53 Correct 107 ms 700 KB Output is correct
54 Correct 111 ms 700 KB Output is correct
55 Correct 69 ms 716 KB Output is correct
56 Correct 75 ms 716 KB Output is correct
57 Correct 45 ms 716 KB Output is correct
58 Correct 98 ms 716 KB Output is correct
59 Correct 101 ms 716 KB Output is correct
60 Correct 111 ms 716 KB Output is correct