답안 #15503

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
15503 2015-07-12T08:33:59 Z indosm 분배 (kriii3_Q) C++14
24 / 24
13 ms 2356 KB
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <algorithm>

#define MAX 12871

using namespace std;

int main()
{
	int a, b, c, d, e, f;
	int com[16][MAX];
	int rst[100000];
	int k, n, cnt = 0, count = 0;
	double K, N;
	int left = 0, right, check = 0;

	scanf("%d %d", &n, &k);
	right = n;

	N = pow(2.0, (double)n);
	K = pow(2.0, (double)k);
	f = INT_MAX - N + 1;
	com[0][0] = 0; com[0][1] = -1; com[right][0] = N - 1; com[right][1] = -1;
	for (a = 0; a<(int)K; a++)
	{
		for (b = 0; b<N / (K * 2); b++)
		{
			if (com[left][check] == -1)
			{
				left++; right--;
				count = 0;
				for (c = 0; c< check; c++)
				{
					for (d = 1; d<=n; d++)
					{
						e = com[left - 1][c];
						if (com[left - 1][c] == (e >> d) << d)
						{
							com[left][count] = e + (int)pow(2.0, (double)(d-1));
							com[right][count] = (~com[left][count]) - f;
							com[right][count] <<= 1;
							com[right][count] >>= 1;
							count++;
						}
					}
				}
				com[left][count] = -1;
				com[right][count] = -1;
				check = 0;

			}
			rst[cnt] = com[left][check];
			if (left == right)
			{
				check++;
			}
			rst[cnt + 1] = com[right][check];
			cnt += 2;
			check++;

		}
		std::sort(rst, rst + cnt);
		printf("%d", rst[0]);
		for (c = 1; c<cnt; c++)
		{
			printf(" %d", rst[c]);
		}
		cnt = 0;
		printf("\n");
	}

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2348 KB Output is correct
2 Correct 0 ms 2356 KB Output is correct
3 Correct 0 ms 2356 KB Output is correct
4 Correct 0 ms 2348 KB Output is correct
5 Correct 0 ms 2352 KB Output is correct
6 Correct 0 ms 2356 KB Output is correct
7 Correct 0 ms 2348 KB Output is correct
8 Correct 0 ms 2352 KB Output is correct
9 Correct 0 ms 2348 KB Output is correct
10 Correct 0 ms 2356 KB Output is correct
11 Correct 0 ms 2352 KB Output is correct
12 Correct 0 ms 2356 KB Output is correct
13 Correct 0 ms 2348 KB Output is correct
14 Correct 0 ms 2356 KB Output is correct
15 Correct 0 ms 2352 KB Output is correct
16 Correct 0 ms 2352 KB Output is correct
17 Correct 0 ms 2352 KB Output is correct
18 Correct 0 ms 2352 KB Output is correct
19 Correct 0 ms 2352 KB Output is correct
20 Correct 0 ms 2356 KB Output is correct
21 Correct 0 ms 2352 KB Output is correct
22 Correct 0 ms 2352 KB Output is correct
23 Correct 0 ms 2352 KB Output is correct
24 Correct 0 ms 2352 KB Output is correct
25 Correct 0 ms 2348 KB Output is correct
26 Correct 0 ms 2352 KB Output is correct
27 Correct 0 ms 2352 KB Output is correct
28 Correct 1 ms 2352 KB Output is correct
29 Correct 0 ms 2352 KB Output is correct
30 Correct 3 ms 2356 KB Output is correct
31 Correct 2 ms 2356 KB Output is correct
32 Correct 2 ms 2352 KB Output is correct
33 Correct 0 ms 2356 KB Output is correct
34 Correct 6 ms 2356 KB Output is correct
35 Correct 0 ms 2352 KB Output is correct
36 Correct 2 ms 2356 KB Output is correct
37 Correct 12 ms 2352 KB Output is correct
38 Correct 13 ms 2352 KB Output is correct
39 Correct 13 ms 2348 KB Output is correct
40 Correct 13 ms 2356 KB Output is correct