# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
15213 |
2015-07-12T03:58:36 Z |
jays |
분배 (kriii3_Q) |
C++14 |
|
0 ms |
3520 KB |
#include <cstdio>
#include <vector>
using namespace std;
int N, K;
int pw2[20];
vector<int> one, num[20], ans[65540];
void solve() {
pw2[0] = 1;
for (int i = 1; i < 20; i++) pw2[i] = pw2[i-1]*2;
for (int i = 0; i <= 1; i++) one.push_back(i);
int cursz = one.size();
while (cursz <= 65540) {
for (int i = 0; i < cursz; i++)
one.push_back(one[i]+1);
cursz = one.size();
}
int tone = 0;
for (int i = 0; i < pw2[N]; i++) {
tone += one[i];
num[one[i]].push_back(i);
}
int perbox = pw2[N]/pw2[K];
for (int i = 0; i < pw2[K]; i++) {
int curone = tone/pw2[K];
for (int j = 0; j < perbox; j++) {
for (int k = curone; k >= 0; k--) {
if (!num[k].empty()) {
ans[i].push_back(num[k].back());
num[k].pop_back();
curone -= k;
break;
}
}
}
}
for (int i = 0; i < pw2[K]; i++) {
for (int j = 0; j < perbox; j++)
printf("%d%c", ans[i][j], " \n"[j == perbox-1]);
}
}
int main() {
scanf("%d%d", &N, &K);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3520 KB |
Output is correct |
2 |
Correct |
0 ms |
3520 KB |
Output is correct |
3 |
Correct |
0 ms |
3520 KB |
Output is correct |
4 |
Incorrect |
0 ms |
3520 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |