답안 #793352

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
793352 2023-07-25T18:15:03 Z rainboy Diamond Hands (innopolis2021_final_B) C
44 / 100
30 ms 5196 KB
#include <stdio.h>

#define N	200000

int abs_(int a) { return a > 0 ? a : -a; }

int main() {
	static int xx[N + 1], yy[N + 1], dd[N + 1], ll[N + 1];
	int n, m, h, i, d, x, y, a, b;

	scanf("%d", &n);
	for (i = 1; i <= n; i++)
		scanf("%d%d", &xx[i], &yy[i]);
	d = 0;
	for (i = 0; i < n; i++) {
		x = xx[i + 1] - xx[i], y = abs_(yy[i + 1] - yy[i]);
		if (y > x || (x + y) % 2 != 0) {
			printf("-1\n");
			return 0;
		}
		if (y == x && d != 0)
			d = (i % 2 == 0) == (yy[i] < yy[i + 1]) ? 1 : -1;
	}
	m = 0;
	for (i = 0; i <= n; i++) {
		x = xx[i + 1] - xx[i], y = yy[i + 1] - yy[i];
		a = (x + y) / 2, b = (x - y) / 2;
		if (d == 1) {
			if (a > 0) {
				if (m == 0 || dd[m - 1] != 1)
					dd[m++] = 1;
				ll[m - 1] += a;
				d = 1;
			}
			if (b > 0) {
				if (m == 0 || dd[m - 1] != -1)
					dd[m++] = -1;
				ll[m - 1] += b;
				d = -1;
			}
		} else {
			if (b > 0) {
				if (m == 0 || dd[m - 1] != -1)
					dd[m++] = -1;
				ll[m - 1] += b;
				d = -1;
			}
			if (a > 0) {
				if (m == 0 || dd[m - 1] != 1)
					dd[m++] = 1;
				ll[m - 1] += a;
				d = 1;
			}
		}
	}
	printf("%d\n", m);
	for (h = 0; h < m; h++)
		printf("%d %c\n", ll[h], dd[h] == 1 ? '+' : '-');
	return 0;
}

Compilation message

Main.c: In function 'main':
Main.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
Main.c:13:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d%d", &xx[i], &yy[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB OK, n=2 ans=1
2 Correct 0 ms 292 KB OK, n=3 ans=1
3 Correct 0 ms 212 KB OK, n=1 ans=1
4 Correct 1 ms 212 KB OK, n=5 ans=1
5 Correct 0 ms 212 KB OK, n=8 ans=1
6 Correct 0 ms 212 KB OK, n=88 ans=1
7 Correct 0 ms 300 KB OK, n=888 ans=1
8 Correct 1 ms 340 KB OK, n=2000 ans=1
9 Correct 1 ms 340 KB OK, n=2000 ans=1
10 Correct 1 ms 340 KB OK, n=2000 ans=1
11 Correct 1 ms 300 KB OK, n=2000 ans=1
12 Correct 0 ms 284 KB OK, n=2 ans=1
13 Correct 0 ms 212 KB OK, n=34 ans=1
14 Correct 0 ms 212 KB OK, n=567 ans=1
15 Correct 0 ms 308 KB OK, n=1234 ans=1
16 Correct 0 ms 212 KB OK, no solution, n=2
17 Correct 0 ms 296 KB OK, no solution, n=3
18 Correct 0 ms 212 KB OK, no solution, n=40
19 Correct 0 ms 212 KB OK, no solution, n=118
20 Correct 1 ms 304 KB OK, no solution, n=2000
21 Correct 1 ms 296 KB OK, no solution, n=2000
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB OK, n=2 ans=1
2 Correct 0 ms 292 KB OK, n=3 ans=1
3 Correct 0 ms 212 KB OK, n=1 ans=1
4 Correct 1 ms 212 KB OK, n=5 ans=1
5 Correct 0 ms 212 KB OK, n=8 ans=1
6 Correct 0 ms 212 KB OK, n=88 ans=1
7 Correct 0 ms 300 KB OK, n=888 ans=1
8 Correct 1 ms 340 KB OK, n=2000 ans=1
9 Correct 1 ms 340 KB OK, n=2000 ans=1
10 Correct 1 ms 340 KB OK, n=2000 ans=1
11 Correct 1 ms 300 KB OK, n=2000 ans=1
12 Correct 0 ms 284 KB OK, n=2 ans=1
13 Correct 0 ms 212 KB OK, n=34 ans=1
14 Correct 0 ms 212 KB OK, n=567 ans=1
15 Correct 0 ms 308 KB OK, n=1234 ans=1
16 Correct 0 ms 212 KB OK, no solution, n=2
17 Correct 0 ms 296 KB OK, no solution, n=3
18 Correct 0 ms 212 KB OK, no solution, n=40
19 Correct 0 ms 212 KB OK, no solution, n=118
20 Correct 1 ms 304 KB OK, no solution, n=2000
21 Correct 1 ms 296 KB OK, no solution, n=2000
22 Correct 0 ms 212 KB OK, n=2 ans=2
23 Correct 0 ms 288 KB OK, n=3 ans=2
24 Correct 0 ms 212 KB OK, n=4 ans=1
25 Incorrect 0 ms 212 KB WA, participant didn't the optimal solution n=5 ans=2 part=3
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB OK, n=2 ans=1
2 Correct 0 ms 292 KB OK, n=3 ans=1
3 Correct 0 ms 212 KB OK, n=1 ans=1
4 Correct 1 ms 212 KB OK, n=5 ans=1
5 Correct 0 ms 212 KB OK, n=8 ans=1
6 Correct 0 ms 212 KB OK, n=88 ans=1
7 Correct 0 ms 300 KB OK, n=888 ans=1
8 Correct 1 ms 340 KB OK, n=2000 ans=1
9 Correct 1 ms 340 KB OK, n=2000 ans=1
10 Correct 1 ms 340 KB OK, n=2000 ans=1
11 Correct 1 ms 300 KB OK, n=2000 ans=1
12 Correct 0 ms 284 KB OK, n=2 ans=1
13 Correct 0 ms 212 KB OK, n=34 ans=1
14 Correct 0 ms 212 KB OK, n=567 ans=1
15 Correct 0 ms 308 KB OK, n=1234 ans=1
16 Correct 0 ms 212 KB OK, no solution, n=2
17 Correct 0 ms 296 KB OK, no solution, n=3
18 Correct 0 ms 212 KB OK, no solution, n=40
19 Correct 0 ms 212 KB OK, no solution, n=118
20 Correct 1 ms 304 KB OK, no solution, n=2000
21 Correct 1 ms 296 KB OK, no solution, n=2000
22 Correct 0 ms 212 KB OK, n=4 ans=2
23 Correct 0 ms 212 KB OK, n=6 ans=2
24 Correct 0 ms 212 KB OK, n=15 ans=2
25 Correct 0 ms 212 KB OK, n=200 ans=2
26 Correct 1 ms 212 KB OK, n=1000 ans=2
27 Correct 2 ms 428 KB OK, n=10000 ans=2
28 Correct 14 ms 2524 KB OK, n=100000 ans=2
29 Correct 25 ms 3620 KB OK, n=159807 ans=2
30 Correct 27 ms 4448 KB OK, n=200000 ans=2
31 Correct 29 ms 4940 KB OK, n=200000 ans=2
32 Correct 30 ms 5196 KB OK, n=200000 ans=2
33 Correct 0 ms 212 KB OK, n=3 ans=2
34 Correct 0 ms 212 KB OK, n=45 ans=2
35 Correct 0 ms 212 KB OK, n=789 ans=2
36 Correct 1 ms 340 KB OK, n=2345 ans=2
37 Correct 11 ms 1988 KB OK, n=67890 ans=2
38 Correct 21 ms 3664 KB OK, no solution, n=159807
39 Correct 26 ms 4476 KB OK, no solution, n=200000
40 Correct 28 ms 4888 KB OK, no solution, n=200000
41 Correct 30 ms 5188 KB OK, no solution, n=200000
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB OK, n=5 ans=3
2 Correct 0 ms 212 KB OK, n=10 ans=4
3 Correct 0 ms 212 KB OK, n=20 ans=5
4 Correct 0 ms 212 KB OK, n=50 ans=9
5 Correct 0 ms 212 KB OK, n=100 ans=18
6 Correct 0 ms 212 KB OK, n=200 ans=46
7 Correct 0 ms 212 KB OK, n=100 ans=5
8 Correct 0 ms 212 KB OK, n=200 ans=20
9 Correct 0 ms 212 KB OK, n=400 ans=76
10 Correct 1 ms 260 KB OK, n=1000 ans=196
11 Correct 0 ms 212 KB OK, n=1000 ans=434
12 Correct 1 ms 304 KB OK, n=1000 ans=582
13 Correct 0 ms 212 KB OK, n=1000 ans=798
14 Correct 0 ms 292 KB OK, n=1000 ans=867
15 Correct 1 ms 340 KB OK, n=2000 ans=200
16 Correct 1 ms 212 KB OK, n=1998 ans=500
17 Correct 1 ms 300 KB OK, n=2000 ans=800
18 Correct 1 ms 304 KB OK, n=1995 ans=1000
19 Correct 1 ms 340 KB OK, n=2000 ans=1500
20 Correct 1 ms 340 KB OK, n=2000 ans=2000
21 Correct 0 ms 212 KB OK, no solution, n=10
22 Correct 0 ms 212 KB OK, no solution, n=50
23 Correct 0 ms 212 KB OK, no solution, n=400
24 Correct 0 ms 212 KB OK, no solution, n=1000
25 Correct 1 ms 212 KB OK, no solution, n=2000
26 Correct 1 ms 224 KB OK, no solution, n=2000
27 Correct 0 ms 212 KB OK, n=4 ans=5
28 Correct 0 ms 212 KB OK, n=30 ans=31
29 Correct 0 ms 292 KB OK, n=500 ans=501
30 Correct 1 ms 296 KB OK, n=1000 ans=1001
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB OK, n=2 ans=1
2 Correct 0 ms 292 KB OK, n=3 ans=1
3 Correct 0 ms 212 KB OK, n=1 ans=1
4 Correct 1 ms 212 KB OK, n=5 ans=1
5 Correct 0 ms 212 KB OK, n=8 ans=1
6 Correct 0 ms 212 KB OK, n=88 ans=1
7 Correct 0 ms 300 KB OK, n=888 ans=1
8 Correct 1 ms 340 KB OK, n=2000 ans=1
9 Correct 1 ms 340 KB OK, n=2000 ans=1
10 Correct 1 ms 340 KB OK, n=2000 ans=1
11 Correct 1 ms 300 KB OK, n=2000 ans=1
12 Correct 0 ms 284 KB OK, n=2 ans=1
13 Correct 0 ms 212 KB OK, n=34 ans=1
14 Correct 0 ms 212 KB OK, n=567 ans=1
15 Correct 0 ms 308 KB OK, n=1234 ans=1
16 Correct 0 ms 212 KB OK, no solution, n=2
17 Correct 0 ms 296 KB OK, no solution, n=3
18 Correct 0 ms 212 KB OK, no solution, n=40
19 Correct 0 ms 212 KB OK, no solution, n=118
20 Correct 1 ms 304 KB OK, no solution, n=2000
21 Correct 1 ms 296 KB OK, no solution, n=2000
22 Correct 0 ms 212 KB OK, n=2 ans=2
23 Correct 0 ms 288 KB OK, n=3 ans=2
24 Correct 0 ms 212 KB OK, n=4 ans=1
25 Incorrect 0 ms 212 KB WA, participant didn't the optimal solution n=5 ans=2 part=3
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB OK, n=2 ans=1
2 Correct 0 ms 292 KB OK, n=3 ans=1
3 Correct 0 ms 212 KB OK, n=1 ans=1
4 Correct 1 ms 212 KB OK, n=5 ans=1
5 Correct 0 ms 212 KB OK, n=8 ans=1
6 Correct 0 ms 212 KB OK, n=88 ans=1
7 Correct 0 ms 300 KB OK, n=888 ans=1
8 Correct 1 ms 340 KB OK, n=2000 ans=1
9 Correct 1 ms 340 KB OK, n=2000 ans=1
10 Correct 1 ms 340 KB OK, n=2000 ans=1
11 Correct 1 ms 300 KB OK, n=2000 ans=1
12 Correct 0 ms 284 KB OK, n=2 ans=1
13 Correct 0 ms 212 KB OK, n=34 ans=1
14 Correct 0 ms 212 KB OK, n=567 ans=1
15 Correct 0 ms 308 KB OK, n=1234 ans=1
16 Correct 0 ms 212 KB OK, no solution, n=2
17 Correct 0 ms 296 KB OK, no solution, n=3
18 Correct 0 ms 212 KB OK, no solution, n=40
19 Correct 0 ms 212 KB OK, no solution, n=118
20 Correct 1 ms 304 KB OK, no solution, n=2000
21 Correct 1 ms 296 KB OK, no solution, n=2000
22 Correct 0 ms 212 KB OK, n=2 ans=2
23 Correct 0 ms 288 KB OK, n=3 ans=2
24 Correct 0 ms 212 KB OK, n=4 ans=1
25 Incorrect 0 ms 212 KB WA, participant didn't the optimal solution n=5 ans=2 part=3
26 Halted 0 ms 0 KB -