답안 #882267

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
882267 2023-12-02T21:13:01 Z rainboy DEL13 (info1cup18_del13) C
40 / 100
10 ms 1368 KB
#include <stdio.h>
#include <string.h>

#define N	100000

int main() {
	int t;

	scanf("%d", &t);
	while (t--) {
		static int ii[N], pp[N + 1];
		int n, m, k, h, i, j, l, r, cnt;

		scanf("%d%d", &n, &m);
		for (h = 0; h < m; h++)
			scanf("%d", &ii[h]), ii[h]--;
		memset(pp, -1, (n + 1) * sizeof *pp), pp[0] = -2;
		for (h = 0; h < m; h++) {
			l = h == 0 ? 0 : ii[h - 1] + 1, r = h + 1 == m ? n : ii[h + 1];
			for (i = l; i < ii[h]; i++)
				if (pp[i] != -1) {
					for (j = ii[h] + 2; j <= r; j++)
						if (j % 2 == (h + 1) % 2)
							pp[j] = i;
					break;
				}
			if (pp[ii[h]] != -1)
				pp[ii[h] + 1] = ii[h];
		}
		if (pp[n] == -1) {
			printf("-1\n");
			continue;
		}
		printf("%d\n", cnt = (n - m) / 2);
		for (h = m - 1, r = n; h >= 0; h--) {
			l = pp[r], r--, i = ii[h];
			if (i - l <= r - i) {
				k = (l + r) / 2 - i;
				while (k--)
					printf("%d%c", i + 3, --cnt == 0 ? '\n' : ' ');
				k = i - l;
				while (k--)
					printf("%d%c", i + 1, --cnt == 0 ? '\n' : ' ');
			} else {
				k = i - (l + r) / 2;
				while (k--)
					printf("%d%c", i - 1, --cnt == 0 ? '\n' : ' ');
				k = r - i;
				while (k--)
					printf("%d%c", i + 1, --cnt == 0 ? '\n' : ' ');
			}
			r = l;
		}
	}
	return 0;
}

Compilation message

del13.c: In function 'main':
del13.c:9:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d", &t);
      |  ^~~~~~~~~~~~~~~
del13.c:14:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d%d", &n, &m);
      |   ^~~~~~~~~~~~~~~~~~~~~
del13.c:16:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |    scanf("%d", &ii[h]), ii[h]--;
      |    ^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is partially correct
2 Correct 1 ms 348 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is partially correct
2 Correct 1 ms 348 KB Output is partially correct
3 Correct 3 ms 344 KB Output is partially correct
4 Correct 3 ms 348 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 852 KB Output is partially correct
2 Correct 1 ms 604 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is partially correct
2 Correct 1 ms 348 KB Output is partially correct
3 Correct 3 ms 344 KB Output is partially correct
4 Correct 3 ms 348 KB Output is partially correct
5 Correct 1 ms 344 KB Output is partially correct
6 Correct 1 ms 348 KB Output is partially correct
7 Correct 1 ms 348 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is partially correct
2 Correct 1 ms 348 KB Output is partially correct
3 Correct 3 ms 344 KB Output is partially correct
4 Correct 3 ms 348 KB Output is partially correct
5 Correct 1 ms 344 KB Output is partially correct
6 Correct 1 ms 348 KB Output is partially correct
7 Correct 1 ms 348 KB Output is partially correct
8 Correct 6 ms 860 KB Output is partially correct
9 Correct 6 ms 856 KB Output is partially correct
10 Correct 5 ms 860 KB Output is partially correct
11 Correct 10 ms 1368 KB Output is partially correct