結果

問題 No.1708 Quality of Contest
ユーザー tailstails
提出日時 2021-11-15 16:45:23
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 1,400 bytes
コンパイル時間 1,507 ms
コンパイル使用メモリ 31,744 KB
実行使用メモリ 9,344 KB
最終ジャッジ日時 2024-12-14 21:55:19
合計ジャッジ時間 2,892 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 1 ms
6,820 KB
testcase_03 AC 2 ms
6,820 KB
testcase_04 AC 1 ms
6,820 KB
testcase_05 AC 1 ms
6,816 KB
testcase_06 AC 2 ms
6,820 KB
testcase_07 AC 2 ms
6,816 KB
testcase_08 AC 2 ms
6,816 KB
testcase_09 AC 16 ms
9,344 KB
testcase_10 AC 15 ms
8,704 KB
testcase_11 AC 15 ms
8,704 KB
testcase_12 AC 16 ms
8,740 KB
testcase_13 AC 16 ms
8,764 KB
testcase_14 AC 16 ms
8,936 KB
testcase_15 AC 17 ms
9,088 KB
testcase_16 AC 16 ms
8,936 KB
testcase_17 AC 14 ms
8,832 KB
testcase_18 AC 14 ms
8,648 KB
testcase_19 AC 16 ms
8,772 KB
testcase_20 AC 15 ms
8,808 KB
testcase_21 AC 17 ms
8,960 KB
testcase_22 AC 17 ms
8,724 KB
testcase_23 AC 17 ms
8,956 KB
testcase_24 AC 15 ms
8,576 KB
testcase_25 AC 16 ms
8,464 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'radix_sort':
main.c:36:20: warning: initialization of 'unsigned int *' from incompatible pointer type 'long unsigned int *' [-Wincompatible-pointer-types]
   36 |         unsigned*b=a+n;
      |                    ^
main.c:37:26: warning: passing argument 2 of 'radix_sort_aux' from incompatible pointer type [-Wincompatible-pointer-types]
   37 |         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:38:24: warning: passing argument 1 of 'radix_sort_aux' from incompatible pointer type [-Wincompatible-pointer-types]
   38 |         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: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:

ソースコード

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[65536];
	for(int i=0;i<65536;++i){
		c[i]=0;
	}
	for(int i=0;i<n;++i){
		++c[a[i]&65535];
	}
	int t=0;
	for(int i=65536;i--;){
		int u=c[i];
		c[i]=t;
		t+=u;
	}
	for(int i=0;i<n;++i){
		b[c[a[i]&65535]++]=a[i]>>16|a[i]<<48;
	}
}

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);
}

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);
}

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