結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 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 1 ms
5,376 KB
testcase_09 AC 14 ms
9,324 KB
testcase_10 AC 14 ms
8,712 KB
testcase_11 AC 16 ms
8,704 KB
testcase_12 AC 15 ms
8,704 KB
testcase_13 AC 15 ms
8,644 KB
testcase_14 AC 17 ms
8,704 KB
testcase_15 AC 18 ms
8,960 KB
testcase_16 AC 19 ms
8,960 KB
testcase_17 AC 15 ms
8,720 KB
testcase_18 AC 15 ms
8,740 KB
testcase_19 AC 17 ms
8,832 KB
testcase_20 AC 16 ms
8,704 KB
testcase_21 AC 16 ms
8,920 KB
testcase_22 AC 16 ms
8,784 KB
testcase_23 AC 18 ms
8,960 KB
testcase_24 AC 14 ms
8,576 KB
testcase_25 AC 16 ms
8,448 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