답안 #111407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
111407 2019-05-15T09:21:49 Z igzi Xylophone (JOI18_xylophone) C++17
100 / 100
122 ms 512 KB
#include <bits/stdc++.h>
#include "xylophone.h"
#define maxN 5005

using namespace std;

int a[maxN];

void solve(int n) {
int i,x,y,p,q;
a[0]=0;
a[1]=query(1,2);
for(i=2;i<n;i++){
x=query(i,i+1);
y=query(i-1,i+1);
if(max(a[i-2],a[i-1]+x)-min(a[i-2],a[i-1])==y) a[i]=a[i-1]+x;
else a[i]=a[i-1]-x;
}
p=-maxN;
q=maxN;
for(i=0;i<n;i++){
    if(a[i]<q){
        q=a[i];
        x=i;
    }
    if(a[i]>p){
        p=a[i];
        y=i;
    }
}
if(y<x){
    for(i=0;i<n;i++){
        a[i]*=-1;
    }
    q=-p;
}
for(i=0;i<n;i++) {a[i]+=1-q; answer(i+1,a[i]);}
}

Compilation message

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:31:1: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
 if(y<x){
 ^~
xylophone.cpp:31:1: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 256 KB Output is correct
14 Correct 6 ms 256 KB Output is correct
15 Correct 4 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 256 KB Output is correct
14 Correct 6 ms 256 KB Output is correct
15 Correct 4 ms 256 KB Output is correct
16 Correct 5 ms 324 KB Output is correct
17 Correct 10 ms 408 KB Output is correct
18 Correct 19 ms 256 KB Output is correct
19 Correct 17 ms 256 KB Output is correct
20 Correct 20 ms 384 KB Output is correct
21 Correct 23 ms 256 KB Output is correct
22 Correct 19 ms 512 KB Output is correct
23 Correct 9 ms 412 KB Output is correct
24 Correct 17 ms 256 KB Output is correct
25 Correct 18 ms 384 KB Output is correct
26 Correct 9 ms 412 KB Output is correct
27 Correct 20 ms 424 KB Output is correct
28 Correct 10 ms 328 KB Output is correct
29 Correct 19 ms 384 KB Output is correct
30 Correct 10 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 256 KB Output is correct
14 Correct 6 ms 256 KB Output is correct
15 Correct 4 ms 256 KB Output is correct
16 Correct 5 ms 324 KB Output is correct
17 Correct 10 ms 408 KB Output is correct
18 Correct 19 ms 256 KB Output is correct
19 Correct 17 ms 256 KB Output is correct
20 Correct 20 ms 384 KB Output is correct
21 Correct 23 ms 256 KB Output is correct
22 Correct 19 ms 512 KB Output is correct
23 Correct 9 ms 412 KB Output is correct
24 Correct 17 ms 256 KB Output is correct
25 Correct 18 ms 384 KB Output is correct
26 Correct 9 ms 412 KB Output is correct
27 Correct 20 ms 424 KB Output is correct
28 Correct 10 ms 328 KB Output is correct
29 Correct 19 ms 384 KB Output is correct
30 Correct 10 ms 324 KB Output is correct
31 Correct 33 ms 384 KB Output is correct
32 Correct 55 ms 328 KB Output is correct
33 Correct 92 ms 376 KB Output is correct
34 Correct 104 ms 340 KB Output is correct
35 Correct 87 ms 388 KB Output is correct
36 Correct 80 ms 332 KB Output is correct
37 Correct 102 ms 424 KB Output is correct
38 Correct 35 ms 416 KB Output is correct
39 Correct 83 ms 336 KB Output is correct
40 Correct 35 ms 328 KB Output is correct
41 Correct 91 ms 504 KB Output is correct
42 Correct 101 ms 256 KB Output is correct
43 Correct 79 ms 384 KB Output is correct
44 Correct 59 ms 328 KB Output is correct
45 Correct 106 ms 404 KB Output is correct
46 Correct 109 ms 256 KB Output is correct
47 Correct 57 ms 376 KB Output is correct
48 Correct 62 ms 376 KB Output is correct
49 Correct 122 ms 256 KB Output is correct
50 Correct 109 ms 452 KB Output is correct
51 Correct 49 ms 436 KB Output is correct
52 Correct 95 ms 408 KB Output is correct
53 Correct 98 ms 512 KB Output is correct
54 Correct 87 ms 372 KB Output is correct
55 Correct 87 ms 412 KB Output is correct
56 Correct 113 ms 256 KB Output is correct
57 Correct 100 ms 256 KB Output is correct
58 Correct 58 ms 384 KB Output is correct
59 Correct 55 ms 448 KB Output is correct
60 Correct 109 ms 460 KB Output is correct