提交记录 13803


用户 题目 状态 得分 用时 内存 语言 代码长度
CraZYali 1001. 测测你的排序 Runtime Error 0 1.608 s 1763916 KB C++11 1.60 KB
提交时间 评测时间
2020-08-11 16:35:45 2020-08-11 16:35:52
/*
	Problem:	1001.cpp
	Time:		2020-08-11 16:02
	Author:		CraZYali
	E-Mail:		yms-chenziyang@outlook.com 
*/

#define REP(i, s, e) for (register int i(s), end_##i(e); i <= end_##i; i++)
#define DEP(i, s, e) for (register int i(s), end_##i(e); i >= end_##i; i--)
#define DEBUG fprintf(stderr, "Passing [%s] in Line %d\n", __FUNCTION__, __LINE__)

#define chkmax(a, b) (a < (b) ? a = (b) : a)
#define chkmin(a, b) (a > (b) ? a = (b) : a)

#include <algorithm>
#include <vector>
#include <iostream>
#include <cstdio>

template <typename T>
inline T read()
{
	T ans = 0, flag = 1;
	char c = getchar();
	while (!isdigit(c))
	{
		if (c == '-') flag = -1;
		c = getchar();
	}
	while (isdigit(c))
	{
		ans = ans * 10 + c - 48;
		c = getchar();
	}
	return ans * flag;
}

#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)

const int w = 16, B = (1 << w) - 1;

const int maxn = 100000000;
std :: pair <unsigned, unsigned> flg[maxn];
std :: vector <std :: pair <unsigned, unsigned> > bin[B + 1];

void sort(unsigned *a, int n)
{
	int times = 32 / w;
	REP(i, 0, n - 1) flg[i] = std :: make_pair(a[i], a[i]);
	while (times--)
	{
		REP(i, 0, n - 1)
		{
			int Old = flg[i].second & B;
			flg[i].second >>= w;
			bin[Old].emplace_back(flg[i]);
		}
		int N = 0;
		REP(i, 0, B)
		{
			for (auto j : bin[i]) flg[N++] = j;
			bin[i].clear();
		}
	}
	REP(i, 0, n - 1) a[i] = flg[i].first;
}

#ifdef CraZYali
unsigned a[maxn];
int main()
{
	file("1001");
	int n = read<int>();
	REP(i, 0, n - 1) scanf("%u", a + i);
	sort(a, n);
	REP(i, 0, n - 1) printf("%u%c", a[i], i == end_i ? '\n' : ' ');
	return 0;
}
#endif

CompilationN/AN/ACompile OKScore: N/A

Testcase #11.608 s1722 MB + 588 KBRuntime ErrorScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2026-03-23 17:06:52 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠