답안 #896131

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
896131 2023-12-31T21:17:25 Z Andrey Xylophone (JOI18_xylophone) C++14
100 / 100
58 ms 600 KB
#include "xylophone.h"
#include<bits/stdc++.h>
using namespace std;

void solve(int N) {
    int n = N;
    vector<int> dif(n-1);
    dif[0] = query(1,2);
    for(int i = 1; i < n-1; i++) {
        dif[i] = query(i+1,i+2);
        if((abs(dif[i-1])+dif[i] == query(i,i+2)) == (dif[i-1] < 0)) {
            dif[i]*=-1;
        }
    }
    vector<int> ans(n);
    ans[0] = 0;
    int sm = 0,p1,p2;
    for(int i = 1; i < n; i++) {
        ans[i] = ans[i-1]+dif[i-1];
        sm = min(sm,ans[i]);
    }
    for(int i = 0; i < n; i++) {
        ans[i] = ans[i]-sm+1;
        if(ans[i] == 1) {
            p1 = i;
        }
        else if(ans[i] == n) {
            p2 = i;
        }
    }
    if(p1 > p2) {
        for(int i = 0; i < n; i++) {
            ans[i] = n-ans[i]+1;
        }
    }
    for(int i = 0; i < n; i++) {
        answer(i+1,ans[i]);
    }
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:31:5: warning: 'p2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |     if(p1 > p2) {
      |     ^~
xylophone.cpp:31:5: warning: 'p1' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 3 ms 432 KB Output is correct
18 Correct 8 ms 444 KB Output is correct
19 Correct 10 ms 600 KB Output is correct
20 Correct 11 ms 440 KB Output is correct
21 Correct 9 ms 440 KB Output is correct
22 Correct 8 ms 416 KB Output is correct
23 Correct 11 ms 436 KB Output is correct
24 Correct 10 ms 436 KB Output is correct
25 Correct 10 ms 436 KB Output is correct
26 Correct 10 ms 428 KB Output is correct
27 Correct 9 ms 440 KB Output is correct
28 Correct 10 ms 412 KB Output is correct
29 Correct 8 ms 436 KB Output is correct
30 Correct 10 ms 444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 3 ms 344 KB Output is correct
17 Correct 3 ms 432 KB Output is correct
18 Correct 8 ms 444 KB Output is correct
19 Correct 10 ms 600 KB Output is correct
20 Correct 11 ms 440 KB Output is correct
21 Correct 9 ms 440 KB Output is correct
22 Correct 8 ms 416 KB Output is correct
23 Correct 11 ms 436 KB Output is correct
24 Correct 10 ms 436 KB Output is correct
25 Correct 10 ms 436 KB Output is correct
26 Correct 10 ms 428 KB Output is correct
27 Correct 9 ms 440 KB Output is correct
28 Correct 10 ms 412 KB Output is correct
29 Correct 8 ms 436 KB Output is correct
30 Correct 10 ms 444 KB Output is correct
31 Correct 28 ms 416 KB Output is correct
32 Correct 30 ms 420 KB Output is correct
33 Correct 39 ms 424 KB Output is correct
34 Correct 48 ms 432 KB Output is correct
35 Correct 48 ms 432 KB Output is correct
36 Correct 50 ms 428 KB Output is correct
37 Correct 44 ms 428 KB Output is correct
38 Correct 45 ms 428 KB Output is correct
39 Correct 55 ms 428 KB Output is correct
40 Correct 48 ms 432 KB Output is correct
41 Correct 36 ms 440 KB Output is correct
42 Correct 45 ms 428 KB Output is correct
43 Correct 51 ms 428 KB Output is correct
44 Correct 50 ms 436 KB Output is correct
45 Correct 38 ms 432 KB Output is correct
46 Correct 47 ms 428 KB Output is correct
47 Correct 46 ms 452 KB Output is correct
48 Correct 45 ms 428 KB Output is correct
49 Correct 49 ms 432 KB Output is correct
50 Correct 46 ms 432 KB Output is correct
51 Correct 51 ms 432 KB Output is correct
52 Correct 53 ms 460 KB Output is correct
53 Correct 57 ms 432 KB Output is correct
54 Correct 47 ms 448 KB Output is correct
55 Correct 48 ms 432 KB Output is correct
56 Correct 52 ms 432 KB Output is correct
57 Correct 56 ms 444 KB Output is correct
58 Correct 44 ms 436 KB Output is correct
59 Correct 58 ms 448 KB Output is correct
60 Correct 45 ms 440 KB Output is correct