# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
15503 | indosm | 분배 (kriii3_Q) | C++14 | 13 ms | 2356 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |