Submission #15191

# Submission time Handle Problem Language Result Execution time Memory
15191 2015-07-12T03:35:57 Z sujin 분배 (kriii3_Q) C++
0 / 24
0 ms 6668 KB
#include <cstdio>

int n,k,m,a[70000];
int o[17][70000],l[17];
int out[17][10000],r[17];

int main ()
{
	int i,j,b,c,t,s;

	scanf ("%d%d",&n,&k);
	for (i=t=1;i<=n;i++,t*=2);
	for (i=0;i<t;i++)
	{
		c=0,s=i;
		while (s)
			c+=s%2,s/=2;
		l[c]++,o[c][l[c]]=i;
	}
	for (m=i=1;i<=k;i++,m*=2);
	b=n,c=0,s=1;
	for (i=0;i<t/2;i++)
	{
		if (++c>l[b])
			c=1,b--;
		out[s][++r[s]]=o[b][c];
		if (n-b==b) c++;
		out[s][++r[s]]=o[n-b][c];
		s=s%m+1;
	}
	for (i=1;i<=m;i++,printf ("\n"))
		for (j=1;j<=r[i];j++)
			printf ("%d ",out[i][j]);
      
   return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6668 KB Output is correct
2 Correct 0 ms 6668 KB Output is correct
3 Correct 0 ms 6668 KB Output is correct
4 Correct 0 ms 6668 KB Output is correct
5 Correct 0 ms 6668 KB Output is correct
6 Correct 0 ms 6668 KB Output is correct
7 Correct 0 ms 6668 KB Output is correct
8 Correct 0 ms 6668 KB Output is correct
9 Correct 0 ms 6668 KB Output is correct
10 Correct 0 ms 6668 KB Output is correct
11 Correct 0 ms 6668 KB Output is correct
12 Correct 0 ms 6668 KB Output is correct
13 Correct 0 ms 6668 KB Output is correct
14 Correct 0 ms 6668 KB Output is correct
15 Incorrect 0 ms 6668 KB Output isn't correct
16 Halted 0 ms 0 KB -