记录编号 |
398360 |
评测结果 |
AAAAAAAAAAE |
题目名称 |
排序测试 |
最终得分 |
90 |
用户昵称 |
sxysxy |
是否通过 |
未通过 |
代码语言 |
C++ |
运行时间 |
1.073 s |
提交时间 |
2017-04-22 08:15:18 |
内存使用 |
47.81 MiB |
显示代码纯文本
#include <cstdio>
#include <cstring>
#include <cstdarg>
#include <cstdlib>
#include <algorithm>
#include <list>
#include <queue>
#include <vector>
#include <cctype>
using namespace std;
const int MAXN = 2000100;
namespace IO{
char buf[1<<20], *fs, *ft;
inline char readc(){
return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<20,stdin)),fs==ft)?0:*fs++;
}
template<typename T>
inline void splay(T &r){
char c;
while((c = readc())){
if(c >= '0' && c <= '9'){
r = c^0x30; break;
}
}while(isdigit(c = readc()))r = r*10+(c^0x30);
}
char opt[1<<24], *op = opt;
char tmp[14];
inline void access(unsigned x){
if(!x){
*op = '0';
*(op+1) = ' ';
op += 2;
return;
}
char *p = tmp;
while(x){
int k = x%10;
x /= 10;
*(++p) = k|0x30;
}
while(*p)*op++ = *p--;
*op++ = ' ';
}
inline void makeroot(){
fwrite(opt, op-opt-1, 1, stdout);
}
}using IO::splay; using IO::access; using IO::makeroot;
unsigned a[MAXN], c[MAXN*3];
unsigned minm[2] = {0, MAXN*3}, maxm[2] = {0, 0};
int main(){
freopen("sorttest.in", "r", stdin);
freopen("sorttest.out", "w", stdout);
unsigned n; splay(n);
unsigned rem = n%4;
unsigned lim = n-rem;
for(register unsigned *pa = a; pa < a+lim; pa += 4){
splay(*(pa)); splay(*(pa+1)); splay(*(pa+2)); splay(*(pa+3));
maxm[*pa > *(maxm+1)] = *pa; minm[*pa < *(minm+1)] = *pa;
maxm[*(pa+1) > *(maxm+1)] = *(pa+1); minm[*(pa+1) < *(minm+1)] = *(pa+1);
maxm[*(pa+2) > *(maxm+1)] = *(pa+2); minm[*(pa+2) < *(minm+1)] = *(pa+2);
maxm[*(pa+3) > *(maxm+1)] = *(pa+3); minm[*(pa+3) < *(minm+1)] = *(pa+3);
c[*pa]++, c[*(pa+1)]++, c[*(pa+2)]++, c[*(pa+3)]++;
}
for(register unsigned *pa = a+lim; pa < a+n; pa++){
splay(*(pa));
maxm[*pa > *(maxm+1)] = *pa; minm[*pa < *(minm+1)] = *pa;
c[*pa]++;
}
maxm[0] = maxm[1];
for(register unsigned f = minm[1]; f <= *maxm; f++)
while(c[f]--)access(f);
makeroot();
return 0;
}