結果

問題 No.1708 Quality of Contest
ユーザー tailstails
提出日時 2021-11-15 16:38:15
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 1,533 bytes
コンパイル時間 995 ms
コンパイル使用メモリ 31,360 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-05-08 16:26:00
合計ジャッジ時間 3,834 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 0 ms
5,376 KB
testcase_09 AC 19 ms
9,088 KB
testcase_10 AC 17 ms
8,576 KB
testcase_11 AC 19 ms
8,448 KB
testcase_12 AC 18 ms
8,448 KB
testcase_13 AC 19 ms
8,448 KB
testcase_14 AC 20 ms
8,576 KB
testcase_15 AC 19 ms
8,704 KB
testcase_16 AC 20 ms
8,704 KB
testcase_17 AC 19 ms
8,576 KB
testcase_18 AC 18 ms
8,576 KB
testcase_19 AC 19 ms
8,576 KB
testcase_20 AC 18 ms
8,576 KB
testcase_21 AC 19 ms
8,704 KB
testcase_22 AC 19 ms
8,576 KB
testcase_23 AC 20 ms
8,704 KB
testcase_24 AC 18 ms
8,320 KB
testcase_25 AC 18 ms
8,192 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'radix_sort':
main.c:38:20: warning: initialization of 'unsigned int *' from incompatible pointer type 'long unsigned int *' [-Wincompatible-pointer-types]
   38 |         unsigned*b=a+n;
      |                    ^
main.c:39:26: warning: passing argument 2 of 'radix_sort_aux' from incompatible pointer type [-Wincompatible-pointer-types]
   39 |         radix_sort_aux(a,b,n);
      |                          ^
      |                          |
      |                          unsigned int *
main.c:10:51: note: expected 'long unsigned int *' but argument is of type 'unsigned int *'
   10 | void radix_sort_aux(unsigned long*a,unsigned long*b,int n){
      |                                     ~~~~~~~~~~~~~~^
main.c:40:24: warning: passing argument 1 of 'radix_sort_aux' from incompatible pointer type [-Wincompatible-pointer-types]
   40 |         radix_sort_aux(b,a,n);
      |                        ^
      |                        |
      |                        unsigned int *
main.c:10:35: note: expected 'long unsigned int *' but argument is of type 'unsigned int *'
   10 | void radix_sort_aux(unsigned long*a,unsigned long*b,int n){
      |                     ~~~~~~~~~~~~~~^
main.c:41:26: warning: passing argument 2 of 'radix_sort_aux' from incompatible pointer type [-Wincompatible-pointer-types]
   41 |         radix_sort_aux(a,b,n);
      |                          ^
      |                          |
      |                          unsigned int *
main.c:10:51: note: expected 'long unsigned int *' but argument is of type 'unsigned int *'
   10 | void radix_sort_aux(unsigned long*a,unsigned long*b,int n){
      |                                     ~~~~~~~~~~~~~~^
main.c:42:24: warning: passing argument 1 of 'radix_sort_aux' from incompatible pointer type [-Wincompatible-pointer-types]
   42 |         radix_sort_aux(b,a,n);
      |                        ^
      |                        |
      |                        unsigned int *
main.c:

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

char*mmap();
#define rd_skip() while(*rp++>=48)
#define rd(v) long v=0;{long _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}
#define wt(v) {long _z=v;do*--wp=_z%10+48;while(_z/=10);}
#define rep(v,e) for(long v=0;v<e;++v)

void radix_sort_aux(unsigned long*a,unsigned long*b,int n){
	int c[256];
	for(int i=0;i<256;++i){
		c[i]=0;
	}
	for(int i=0;i<n;++i){
		++c[a[i]&255];
	}
	int t=0;
	for(int i=256;i--;){
		int u=c[i];
		c[i]=t;
		t+=u;
	}
	for(int i=0;i<n;++i){
		b[c[a[i]&255]++]=a[i]>>8|a[i]<<56;
	}
}

void radix_sort_32(unsigned long*a,int n){
	unsigned long*b=a+n;
	radix_sort_aux(a,b,n);
	radix_sort_aux(b,a,n);
	radix_sort_aux(a,b,n);
	radix_sort_aux(b,a,n);
}

void radix_sort(unsigned long*a,int n){
	unsigned*b=a+n;
	radix_sort_aux(a,b,n);
	radix_sort_aux(b,a,n);
	radix_sort_aux(a,b,n);
	radix_sort_aux(b,a,n);
	radix_sort_aux(a,b,n);
	radix_sort_aux(b,a,n);
	radix_sort_aux(a,b,n);
	radix_sort_aux(b,a,n);
}

unsigned long ab[400000];
char u[200001];

main(){
	char*rp=mmap(0l,1l<<25,1,2,0,0ll);
	rd(n);
	rd_skip();
	rd(x);
	rep(i,n){
		rd(a);
		rd(b);
		ab[i]=a|b<<32;
	}
	radix_sort_32(ab,n);
	rep(i,n){
		long a=ab[i]>>32;
		long b=(unsigned)ab[i];
		if(!u[b]){
			u[b]=1;
			a+=x;
		}
		ab[i]=a;
	}
	radix_sort(ab,n);
	{
		long s=0;
		rep(i,n){
			long t=s+ab[i];
			ab[i]=s;
			s=t;
		}
		ab[n]=s;
	}
	{
		rd(k);
		long z=0;
		rep(i,k){
			rd(c);
			z+=ab[c];
		}
		char wbuf[64],*wp=wbuf+sizeof wbuf;
		wt(z);
		write(1,wp,wbuf+sizeof wbuf-wp);
	}
	_exit(0);
}
0