結果

問題 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
コンパイル時間 701 ms
コンパイル使用メモリ 30,940 KB
実行使用メモリ 9,420 KB
最終ジャッジ日時 2023-08-21 11:15:49
合計ジャッジ時間 2,257 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 14 ms
9,420 KB
testcase_10 AC 15 ms
8,808 KB
testcase_11 AC 17 ms
8,872 KB
testcase_12 AC 16 ms
8,872 KB
testcase_13 AC 16 ms
8,788 KB
testcase_14 AC 17 ms
8,948 KB
testcase_15 AC 17 ms
9,084 KB
testcase_16 AC 17 ms
9,092 KB
testcase_17 AC 15 ms
8,816 KB
testcase_18 AC 16 ms
8,832 KB
testcase_19 AC 16 ms
8,804 KB
testcase_20 AC 16 ms
8,756 KB
testcase_21 AC 17 ms
9,004 KB
testcase_22 AC 17 ms
8,904 KB
testcase_23 AC 17 ms
9,156 KB
testcase_24 AC 16 ms
8,516 KB
testcase_25 AC 15 ms
8,612 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘radix_sort’ 内:
main.c:36:20: 警告: initialization of ‘unsigned int *’ from incompatible pointer type ‘long unsigned int *’ [-Wincompatible-pointer-types]
   36 |         unsigned*b=a+n;
      |                    ^
main.c:37:26: 警告: 互換性のないポインタ型から 2 番目の ‘radix_sort_aux’ の引数に渡しています [-Wincompatible-pointer-types]
   37 |         radix_sort_aux(a,b,n);
      |                          ^
      |                          |
      |                          unsigned int *
main.c:10:51: 備考: 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: 警告: 互換性のないポインタ型から 1 番目の ‘radix_sort_aux’ の引数に渡しています [-Wincompatible-pointer-types]
   38 |         radix_sort_aux(b,a,n);
      |                        ^
      |                        |
      |                        unsigned int *
main.c:10:35: 備考: 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: 警告: 互換性のないポインタ型から 2 番目の ‘radix_sort_aux’ の引数に渡しています [-Wincompatible-pointer-types]
   39 |         radix_sort_aux(a,b,n);
      |                          ^
      |                          |
      |                          unsigned int *
main.c:10:51: 備考: 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: 警告: 互換性のないポインタ型から 1 番目の ‘radix_sort_aux’ の引数に渡しています [-Wincompatible-p

ソースコード

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