Submission #147833

# Submission time Handle Problem Language Result Execution time Memory
147833 2019-08-30T21:30:54 Z mosiashvililuka Xylophone (JOI18_xylophone) C++14
100 / 100
120 ms 528 KB
#include<bits/stdc++.h>
#include "xylophone.h"
using namespace std;
int a,b,c,d,e,n,f[5009],mn,cc;
void solve(int n){
	a=query(1,2);
	mn=n*2;
	f[1]=0;
	f[2]=a;
	for(c=2; c<n; c++){
		a=abs(f[c]-f[c-1]);
		if(f[c]>f[c-1]){
			b=query(c,c+1);
			cc=query(c-1,c+1);
			if(cc==a+b){
				f[c+1]=f[c]+b;
			}else{
				f[c+1]=f[c]-b;
			}
		}else{
			b=query(c,c+1);
			cc=query(c-1,c+1);
			if(cc==a+b){
				f[c+1]=f[c]-b;
			}else{
				f[c+1]=f[c]+b;
			}
		}
	}
	int mx=-mn;
	for(c=1; c<=n; c++){
		if(mn>f[c]){
			mn=f[c];
			d=c;
		}
		if(mx<f[c]){
			mx=f[c];
			e=c;
		}
	}
	if(d>e){
		for(c=1; c<=n; c++) f[c]=-f[c];
	}
	mn=n*2;
	for(c=1; c<=n; c++) if(mn>f[c]) mn=f[c];
	for(c=1; c<=n; c++){
		answer(c,f[c]-mn+1);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 4 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 248 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 4 ms 252 KB Output is correct
9 Correct 4 ms 248 KB Output is correct
10 Correct 5 ms 248 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 4 ms 248 KB Output is correct
13 Correct 5 ms 252 KB Output is correct
14 Correct 5 ms 248 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 4 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 248 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 4 ms 252 KB Output is correct
9 Correct 4 ms 248 KB Output is correct
10 Correct 5 ms 248 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 4 ms 248 KB Output is correct
13 Correct 5 ms 252 KB Output is correct
14 Correct 5 ms 248 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 10 ms 248 KB Output is correct
17 Correct 10 ms 248 KB Output is correct
18 Correct 23 ms 248 KB Output is correct
19 Correct 26 ms 376 KB Output is correct
20 Correct 14 ms 324 KB Output is correct
21 Correct 23 ms 408 KB Output is correct
22 Correct 21 ms 248 KB Output is correct
23 Correct 21 ms 376 KB Output is correct
24 Correct 20 ms 248 KB Output is correct
25 Correct 23 ms 376 KB Output is correct
26 Correct 19 ms 376 KB Output is correct
27 Correct 20 ms 248 KB Output is correct
28 Correct 24 ms 248 KB Output is correct
29 Correct 25 ms 376 KB Output is correct
30 Correct 23 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 4 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 4 ms 248 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 4 ms 252 KB Output is correct
9 Correct 4 ms 248 KB Output is correct
10 Correct 5 ms 248 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 4 ms 248 KB Output is correct
13 Correct 5 ms 252 KB Output is correct
14 Correct 5 ms 248 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 10 ms 248 KB Output is correct
17 Correct 10 ms 248 KB Output is correct
18 Correct 23 ms 248 KB Output is correct
19 Correct 26 ms 376 KB Output is correct
20 Correct 14 ms 324 KB Output is correct
21 Correct 23 ms 408 KB Output is correct
22 Correct 21 ms 248 KB Output is correct
23 Correct 21 ms 376 KB Output is correct
24 Correct 20 ms 248 KB Output is correct
25 Correct 23 ms 376 KB Output is correct
26 Correct 19 ms 376 KB Output is correct
27 Correct 20 ms 248 KB Output is correct
28 Correct 24 ms 248 KB Output is correct
29 Correct 25 ms 376 KB Output is correct
30 Correct 23 ms 248 KB Output is correct
31 Correct 32 ms 376 KB Output is correct
32 Correct 34 ms 404 KB Output is correct
33 Correct 67 ms 424 KB Output is correct
34 Correct 70 ms 380 KB Output is correct
35 Correct 89 ms 328 KB Output is correct
36 Correct 109 ms 320 KB Output is correct
37 Correct 76 ms 376 KB Output is correct
38 Correct 68 ms 328 KB Output is correct
39 Correct 102 ms 448 KB Output is correct
40 Correct 115 ms 376 KB Output is correct
41 Correct 102 ms 420 KB Output is correct
42 Correct 93 ms 376 KB Output is correct
43 Correct 110 ms 460 KB Output is correct
44 Correct 105 ms 376 KB Output is correct
45 Correct 120 ms 248 KB Output is correct
46 Correct 102 ms 248 KB Output is correct
47 Correct 117 ms 376 KB Output is correct
48 Correct 116 ms 464 KB Output is correct
49 Correct 101 ms 380 KB Output is correct
50 Correct 104 ms 424 KB Output is correct
51 Correct 107 ms 248 KB Output is correct
52 Correct 85 ms 528 KB Output is correct
53 Correct 79 ms 376 KB Output is correct
54 Correct 55 ms 320 KB Output is correct
55 Correct 104 ms 376 KB Output is correct
56 Correct 98 ms 504 KB Output is correct
57 Correct 108 ms 416 KB Output is correct
58 Correct 100 ms 452 KB Output is correct
59 Correct 85 ms 452 KB Output is correct
60 Correct 102 ms 324 KB Output is correct