Submission #20696

# Submission time Handle Problem Language Result Execution time Memory
20696 2017-02-13T14:17:27 Z alex9801 == gs13105(#83, gs13105) Can polan into space? (OJUZ11_space) C++14
72 / 100
1000 ms 28036 KB
#include <stdio.h>
#include <string.h>
#include <algorithm>

int a[3][200001];

long long m1[4][524300];
int m2[4][524300];

void f(int h, int l, int r, int le, int re)
{
	int q = le*2 + re;

	if(l==r)
	{
		m1[q][h] = a[le+re][l];
		m2[q][h] = 0;
		return;
	}

	if(l+1 == r)
	{
		int t1 = a[le+1][l] + a[re][r];
		int t2 = a[le][l] + a[re+1][r];

		if(t1 >= t2)
		{
			m1[q][h] = t1;
			m2[q][h] = -1;
		}
		else
		{
			m1[q][h] = t2;
			m2[q][h] = -2;
		}
		return;
	}

	int x = (l+r)/2;

	f(2*h, l, x-1, le, 0);
	f(2*h, l, x-1, le, 1);
	f(2*h+1, x+1, r, 0, re);
	f(2*h+1, x+1, r, 1, re);

	long long tl0 = m1[2*le][2*h];
	long long tl1 = m1[2*le+1][2*h];
	long long tr0 = m1[re][2*h+1];
	long long tr1 = m1[2+re][2*h+1];

	long long p1 = a[2][x] + tl0 + tr0;
	long long p2 = a[1][x] + tl1 + tr0;
	long long p3 = a[0][x] + tl1 + tr1;
	long long p4 = a[1][x] + tl0 + tr1;
	long long p5 = a[0][x] + tl1 + tr1;

	long long pm = std::max({p1, p2, p3, p4, p5});

	m1[q][h] = pm;

	if(p1 == pm)
		m2[q][h] = 1;
	else if(p2 == pm)
		m2[q][h] = 2;
	else if(p3 == pm)
		m2[q][h] = 3;
	else if(p4 == pm)
		m2[q][h] = 4;
	else if(p5 == pm)
		m2[q][h] = 5;
}

void g(int h, int l, int r, int le, int re)
{
	int q = le*2 + re;
	int x = (l+r)/2;

	switch(m2[q][h])
	{
	case 0:
		printf("%d ", l);
		break;
	case -1:
		printf("%d %d ", l, r);
		break;
	case -2:
		printf("%d %d ", r, l);
		break;
	case 1:
		printf("%d ", x);
		g(2*h, l, x-1, le, 0);
		g(2*h+1, x+1, r, 0, re);
		break;
	case 2:
		g(2*h, l, x-1, le, 1);
		printf("%d ", x);
		g(2*h+1, x+1, r, 0, re);
		break;
	case 3:
		g(2*h, l, x-1, le, 1);
		g(2*h+1, x+1, r, 1, re);
		printf("%d ", x);
		break;
	case 4:
		g(2*h+1, x+1, r, 1, re);
		printf("%d ", x);
		g(2*h, l, x-1, le, 0);
		break;
	case 5:
		g(2*h+1, x+1, r, 1, re);
		g(2*h, l, x-1, le, 1);
		printf("%d ", x);
		break;
	}
}

int main()
{
	int n, i;
	scanf("%d", &n);
	for(i = 1; i<=n; i++)
		scanf("%d%d%d", &a[2][i], &a[1][i], &a[0][i]);

	f(1, 1, n, 1, 1);

	printf("%lld\n", m1[3][1]);

	g(1, 1, n, 1, 1);
	
	return 0;
}

Compilation message

space.cpp: In function 'int main()':
space.cpp:120:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
space.cpp:122:48: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &a[2][i], &a[1][i], &a[0][i]);
                                                ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 28036 KB Output is correct
2 Correct 0 ms 28036 KB Output is correct
3 Correct 0 ms 28036 KB Output is correct
4 Correct 0 ms 28036 KB Output is correct
5 Correct 0 ms 28036 KB Output is correct
6 Correct 0 ms 28036 KB Output is correct
7 Correct 0 ms 28036 KB Output is correct
8 Correct 0 ms 28036 KB Output is correct
9 Correct 0 ms 28036 KB Output is correct
10 Correct 0 ms 28036 KB Output is correct
11 Correct 0 ms 28036 KB Output is correct
12 Correct 0 ms 28036 KB Output is correct
13 Correct 0 ms 28036 KB Output is correct
14 Correct 0 ms 28036 KB Output is correct
15 Correct 0 ms 28036 KB Output is correct
16 Correct 0 ms 28036 KB Output is correct
17 Correct 0 ms 28036 KB Output is correct
18 Correct 0 ms 28036 KB Output is correct
19 Correct 0 ms 28036 KB Output is correct
20 Correct 0 ms 28036 KB Output is correct
21 Correct 0 ms 28036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 28036 KB Output is correct
2 Correct 0 ms 28036 KB Output is correct
3 Correct 0 ms 28036 KB Output is correct
4 Correct 0 ms 28036 KB Output is correct
5 Correct 0 ms 28036 KB Output is correct
6 Correct 0 ms 28036 KB Output is correct
7 Correct 0 ms 28036 KB Output is correct
8 Correct 0 ms 28036 KB Output is correct
9 Correct 0 ms 28036 KB Output is correct
10 Correct 0 ms 28036 KB Output is correct
11 Correct 0 ms 28036 KB Output is correct
12 Correct 0 ms 28036 KB Output is correct
13 Correct 0 ms 28036 KB Output is correct
14 Correct 0 ms 28036 KB Output is correct
15 Correct 0 ms 28036 KB Output is correct
16 Correct 0 ms 28036 KB Output is correct
17 Correct 0 ms 28036 KB Output is correct
18 Correct 0 ms 28036 KB Output is correct
19 Correct 0 ms 28036 KB Output is correct
20 Correct 0 ms 28036 KB Output is correct
21 Correct 0 ms 28036 KB Output is correct
22 Correct 0 ms 28036 KB Output is correct
23 Correct 0 ms 28036 KB Output is correct
24 Correct 0 ms 28036 KB Output is correct
25 Correct 0 ms 28036 KB Output is correct
26 Correct 0 ms 28036 KB Output is correct
27 Correct 0 ms 28036 KB Output is correct
28 Correct 0 ms 28036 KB Output is correct
29 Correct 0 ms 28036 KB Output is correct
30 Correct 0 ms 28036 KB Output is correct
31 Correct 0 ms 28036 KB Output is correct
32 Correct 0 ms 28036 KB Output is correct
33 Correct 0 ms 28036 KB Output is correct
34 Correct 0 ms 28036 KB Output is correct
35 Correct 0 ms 28036 KB Output is correct
36 Correct 0 ms 28036 KB Output is correct
37 Correct 0 ms 28036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 28036 KB Output is correct
2 Correct 0 ms 28036 KB Output is correct
3 Correct 0 ms 28036 KB Output is correct
4 Correct 0 ms 28036 KB Output is correct
5 Correct 0 ms 28036 KB Output is correct
6 Correct 0 ms 28036 KB Output is correct
7 Correct 0 ms 28036 KB Output is correct
8 Correct 0 ms 28036 KB Output is correct
9 Correct 0 ms 28036 KB Output is correct
10 Correct 0 ms 28036 KB Output is correct
11 Correct 0 ms 28036 KB Output is correct
12 Correct 0 ms 28036 KB Output is correct
13 Correct 0 ms 28036 KB Output is correct
14 Correct 0 ms 28036 KB Output is correct
15 Correct 0 ms 28036 KB Output is correct
16 Correct 0 ms 28036 KB Output is correct
17 Correct 0 ms 28036 KB Output is correct
18 Correct 0 ms 28036 KB Output is correct
19 Correct 0 ms 28036 KB Output is correct
20 Correct 0 ms 28036 KB Output is correct
21 Correct 0 ms 28036 KB Output is correct
22 Correct 0 ms 28036 KB Output is correct
23 Correct 0 ms 28036 KB Output is correct
24 Correct 0 ms 28036 KB Output is correct
25 Correct 0 ms 28036 KB Output is correct
26 Correct 0 ms 28036 KB Output is correct
27 Correct 0 ms 28036 KB Output is correct
28 Correct 0 ms 28036 KB Output is correct
29 Correct 0 ms 28036 KB Output is correct
30 Correct 0 ms 28036 KB Output is correct
31 Correct 0 ms 28036 KB Output is correct
32 Correct 0 ms 28036 KB Output is correct
33 Correct 0 ms 28036 KB Output is correct
34 Correct 0 ms 28036 KB Output is correct
35 Correct 0 ms 28036 KB Output is correct
36 Correct 0 ms 28036 KB Output is correct
37 Correct 0 ms 28036 KB Output is correct
38 Correct 0 ms 28036 KB Output is correct
39 Correct 0 ms 28036 KB Output is correct
40 Correct 0 ms 28036 KB Output is correct
41 Correct 0 ms 28036 KB Output is correct
42 Correct 0 ms 28036 KB Output is correct
43 Correct 0 ms 28036 KB Output is correct
44 Correct 0 ms 28036 KB Output is correct
45 Correct 0 ms 28036 KB Output is correct
46 Correct 0 ms 28036 KB Output is correct
47 Correct 0 ms 28036 KB Output is correct
48 Correct 0 ms 28036 KB Output is correct
49 Correct 0 ms 28036 KB Output is correct
50 Correct 0 ms 28036 KB Output is correct
51 Correct 0 ms 28036 KB Output is correct
52 Correct 0 ms 28036 KB Output is correct
53 Correct 0 ms 28036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 28036 KB Output is correct
2 Correct 0 ms 28036 KB Output is correct
3 Correct 0 ms 28036 KB Output is correct
4 Correct 0 ms 28036 KB Output is correct
5 Correct 0 ms 28036 KB Output is correct
6 Correct 0 ms 28036 KB Output is correct
7 Correct 0 ms 28036 KB Output is correct
8 Correct 0 ms 28036 KB Output is correct
9 Correct 0 ms 28036 KB Output is correct
10 Correct 0 ms 28036 KB Output is correct
11 Correct 0 ms 28036 KB Output is correct
12 Correct 0 ms 28036 KB Output is correct
13 Correct 0 ms 28036 KB Output is correct
14 Correct 0 ms 28036 KB Output is correct
15 Correct 0 ms 28036 KB Output is correct
16 Correct 0 ms 28036 KB Output is correct
17 Correct 0 ms 28036 KB Output is correct
18 Correct 0 ms 28036 KB Output is correct
19 Correct 0 ms 28036 KB Output is correct
20 Correct 0 ms 28036 KB Output is correct
21 Correct 0 ms 28036 KB Output is correct
22 Correct 0 ms 28036 KB Output is correct
23 Correct 0 ms 28036 KB Output is correct
24 Correct 0 ms 28036 KB Output is correct
25 Correct 0 ms 28036 KB Output is correct
26 Correct 0 ms 28036 KB Output is correct
27 Correct 0 ms 28036 KB Output is correct
28 Correct 0 ms 28036 KB Output is correct
29 Correct 0 ms 28036 KB Output is correct
30 Correct 0 ms 28036 KB Output is correct
31 Correct 0 ms 28036 KB Output is correct
32 Correct 0 ms 28036 KB Output is correct
33 Correct 0 ms 28036 KB Output is correct
34 Correct 0 ms 28036 KB Output is correct
35 Correct 0 ms 28036 KB Output is correct
36 Correct 0 ms 28036 KB Output is correct
37 Correct 0 ms 28036 KB Output is correct
38 Correct 0 ms 28036 KB Output is correct
39 Correct 0 ms 28036 KB Output is correct
40 Correct 0 ms 28036 KB Output is correct
41 Correct 0 ms 28036 KB Output is correct
42 Correct 0 ms 28036 KB Output is correct
43 Correct 0 ms 28036 KB Output is correct
44 Correct 0 ms 28036 KB Output is correct
45 Correct 0 ms 28036 KB Output is correct
46 Correct 0 ms 28036 KB Output is correct
47 Correct 0 ms 28036 KB Output is correct
48 Correct 0 ms 28036 KB Output is correct
49 Correct 0 ms 28036 KB Output is correct
50 Correct 0 ms 28036 KB Output is correct
51 Correct 0 ms 28036 KB Output is correct
52 Correct 0 ms 28036 KB Output is correct
53 Correct 0 ms 28036 KB Output is correct
54 Correct 0 ms 28036 KB Output is correct
55 Correct 249 ms 28036 KB Output is correct
56 Correct 256 ms 28036 KB Output is correct
57 Correct 259 ms 28036 KB Output is correct
58 Correct 269 ms 28036 KB Output is correct
59 Correct 243 ms 28036 KB Output is correct
60 Correct 246 ms 28036 KB Output is correct
61 Correct 233 ms 28036 KB Output is correct
62 Correct 149 ms 28036 KB Output is correct
63 Correct 13 ms 28036 KB Output is correct
64 Correct 266 ms 28036 KB Output is correct
65 Correct 246 ms 28036 KB Output is correct
66 Correct 246 ms 28036 KB Output is correct
67 Correct 63 ms 28036 KB Output is correct
68 Correct 19 ms 28036 KB Output is correct
69 Correct 236 ms 28036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 28036 KB Output is correct
2 Correct 0 ms 28036 KB Output is correct
3 Correct 0 ms 28036 KB Output is correct
4 Correct 0 ms 28036 KB Output is correct
5 Correct 0 ms 28036 KB Output is correct
6 Correct 0 ms 28036 KB Output is correct
7 Correct 0 ms 28036 KB Output is correct
8 Correct 0 ms 28036 KB Output is correct
9 Correct 0 ms 28036 KB Output is correct
10 Correct 0 ms 28036 KB Output is correct
11 Correct 0 ms 28036 KB Output is correct
12 Correct 0 ms 28036 KB Output is correct
13 Correct 0 ms 28036 KB Output is correct
14 Correct 0 ms 28036 KB Output is correct
15 Correct 0 ms 28036 KB Output is correct
16 Correct 0 ms 28036 KB Output is correct
17 Correct 0 ms 28036 KB Output is correct
18 Correct 0 ms 28036 KB Output is correct
19 Correct 0 ms 28036 KB Output is correct
20 Correct 0 ms 28036 KB Output is correct
21 Correct 0 ms 28036 KB Output is correct
22 Correct 0 ms 28036 KB Output is correct
23 Correct 0 ms 28036 KB Output is correct
24 Correct 0 ms 28036 KB Output is correct
25 Correct 0 ms 28036 KB Output is correct
26 Correct 0 ms 28036 KB Output is correct
27 Correct 0 ms 28036 KB Output is correct
28 Correct 0 ms 28036 KB Output is correct
29 Correct 0 ms 28036 KB Output is correct
30 Correct 0 ms 28036 KB Output is correct
31 Correct 0 ms 28036 KB Output is correct
32 Correct 0 ms 28036 KB Output is correct
33 Correct 0 ms 28036 KB Output is correct
34 Correct 0 ms 28036 KB Output is correct
35 Correct 0 ms 28036 KB Output is correct
36 Correct 0 ms 28036 KB Output is correct
37 Correct 0 ms 28036 KB Output is correct
38 Correct 0 ms 28036 KB Output is correct
39 Correct 0 ms 28036 KB Output is correct
40 Correct 0 ms 28036 KB Output is correct
41 Correct 0 ms 28036 KB Output is correct
42 Correct 0 ms 28036 KB Output is correct
43 Correct 0 ms 28036 KB Output is correct
44 Correct 0 ms 28036 KB Output is correct
45 Correct 0 ms 28036 KB Output is correct
46 Correct 0 ms 28036 KB Output is correct
47 Correct 0 ms 28036 KB Output is correct
48 Correct 0 ms 28036 KB Output is correct
49 Correct 0 ms 28036 KB Output is correct
50 Correct 0 ms 28036 KB Output is correct
51 Correct 0 ms 28036 KB Output is correct
52 Correct 0 ms 28036 KB Output is correct
53 Correct 0 ms 28036 KB Output is correct
54 Correct 0 ms 28036 KB Output is correct
55 Correct 249 ms 28036 KB Output is correct
56 Correct 256 ms 28036 KB Output is correct
57 Correct 259 ms 28036 KB Output is correct
58 Correct 269 ms 28036 KB Output is correct
59 Correct 243 ms 28036 KB Output is correct
60 Correct 246 ms 28036 KB Output is correct
61 Correct 233 ms 28036 KB Output is correct
62 Correct 149 ms 28036 KB Output is correct
63 Correct 13 ms 28036 KB Output is correct
64 Correct 266 ms 28036 KB Output is correct
65 Correct 246 ms 28036 KB Output is correct
66 Correct 246 ms 28036 KB Output is correct
67 Correct 63 ms 28036 KB Output is correct
68 Correct 19 ms 28036 KB Output is correct
69 Correct 236 ms 28036 KB Output is correct
70 Correct 243 ms 28036 KB Output is correct
71 Execution timed out 1000 ms 28036 KB Execution timed out
72 Execution timed out 1000 ms 28036 KB Execution timed out
73 Execution timed out 1000 ms 28036 KB Execution timed out
74 Execution timed out 1000 ms 28036 KB Execution timed out
75 Execution timed out 1000 ms 28036 KB Execution timed out
76 Execution timed out 1000 ms 28036 KB Execution timed out
77 Execution timed out 1000 ms 28036 KB Execution timed out
78 Execution timed out 1000 ms 28036 KB Execution timed out
79 Execution timed out 1000 ms 28036 KB Execution timed out
80 Execution timed out 1000 ms 28036 KB Execution timed out
81 Execution timed out 1000 ms 28036 KB Execution timed out
82 Execution timed out 1000 ms 28036 KB Execution timed out
83 Execution timed out 1000 ms 28036 KB Execution timed out
84 Execution timed out 1000 ms 28036 KB Execution timed out
85 Execution timed out 1000 ms 28036 KB Execution timed out
86 Execution timed out 1000 ms 28036 KB Execution timed out
87 Execution timed out 1000 ms 28036 KB Execution timed out
88 Execution timed out 1000 ms 28036 KB Execution timed out
89 Execution timed out 1000 ms 28036 KB Execution timed out
90 Execution timed out 1000 ms 28036 KB Execution timed out
91 Correct 256 ms 28036 KB Output is correct
92 Execution timed out 1000 ms 28036 KB Execution timed out