結果

問題 No.1722 [Cherry 3rd Tune C] In my way
ユーザー tailstails
提出日時 2021-11-03 16:06:27
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,441 bytes
コンパイル時間 821 ms
コンパイル使用メモリ 33,408 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 07:19:12
合計ジャッジ時間 1,559 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 AC 0 ms
5,376 KB
testcase_07 AC 0 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 0 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'f2':
main.c:73:25: warning: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration]
   73 |                         memcpy(wp,"Infinity\n",9);
      |                         ^~~~~~
main.c:1:1: note: include '<string.h>' or provide a declaration of 'memcpy'
  +++ |+#include <string.h>
    1 | #pragma GCC optimize("Ofast")
main.c:73:25: warning: incompatible implicit declaration of built-in function 'memcpy' [-Wbuiltin-declaration-mismatch]
   73 |                         memcpy(wp,"Infinity\n",9);
      |                         ^~~~~~
main.c:73:25: note: include '<string.h>' or provide a declaration of 'memcpy'
main.c:77:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   77 |         write(1,wbuf,wp-wbuf);
      |         ^~~~~
main.c:78:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   78 |         _exit(0);
      |         ^~~~~
      |         _Exit
main.c: At top level:
main.c:81:1: warning: return type defaults to 'int' [-Wimplicit-int]
   81 | main(){
      | ^~~~

ソースコード

diff #

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

char*mmap();
#define rd(v) long v=0;{long _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}

char wbuf[1<<25];

#define WTHI(v) {long _z=v,_n=0,_d=0;while(++_n,_d=_d<<8|0x30|_z%10,_z/=10);*(long*)wp=_d;wp+=_n;}
#define WTLO(v) {long _z=v,_n=8,_d=0;while(_d=_d<<8|0x30|_z%10,_z/=10,--_n);*(long*)wp=_d;wp+=8;}
#define wt(v) if(v>=100000000){WTHI(v/100000000);WTLO(v);}else{WTHI(v);}

#define rep(v,e) for(long v=0;v<e;++v)

void radix_sort_aux(unsigned*a,unsigned*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=0;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]<<24;
	}
}

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

int x[1000],y[2000];

void f1(char*rp,long n,long m){
	rep(i,n){
		rd(xi);
		x[i]=xi;
	}
	rep(j,m){
		rd(yj);
		y[j]=yj;
	}
	radix_sort(y,m);
}

void f2(long n,long m){
	char*wp=wbuf;
	rep(i,n){
		long xi=x[i];
		long l=-1,h=m;
		while(l+1<h){
			long j=l+h>>1;
			if(y[j]<xi){
				l=j;
			}else{
				h=j;
			}
		}
		if(h<m){
			long z=y[h]-xi;
			wt(z);
			*wp++='\n';
		}else{
			memcpy(wp,"Infinity\n",9);
			wp+=9;
		}
	}
	write(1,wbuf,wp-wbuf);
	_exit(0);
}

main(){
	char*rp=mmap(0l,1l<<25,1,2,0,0ll);
	rd(n);
	rd(m);
	f1(rp,n,m);
	f2(n,m);
}
0