結果
問題 | No.938 賢人を探せ |
ユーザー | tails |
提出日時 | 2021-01-19 09:23:21 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 776 bytes |
コンパイル時間 | 1,121 ms |
コンパイル使用メモリ | 30,336 KB |
実行使用メモリ | 10,468 KB |
最終ジャッジ日時 | 2024-05-09 11:51:24 |
合計ジャッジ時間 | 1,693 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 11 ms
10,468 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,944 KB |
testcase_07 | AC | 1 ms
6,940 KB |
testcase_08 | AC | 4 ms
6,940 KB |
testcase_09 | AC | 4 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | AC | 5 ms
6,944 KB |
testcase_12 | AC | 4 ms
6,944 KB |
testcase_13 | AC | 4 ms
6,940 KB |
testcase_14 | AC | 4 ms
6,944 KB |
testcase_15 | AC | 4 ms
6,940 KB |
testcase_16 | AC | 4 ms
6,940 KB |
testcase_17 | AC | 4 ms
6,940 KB |
testcase_18 | AC | 5 ms
6,944 KB |
testcase_19 | AC | 4 ms
6,940 KB |
testcase_20 | AC | 3 ms
6,940 KB |
testcase_21 | AC | 3 ms
6,940 KB |
testcase_22 | AC | 5 ms
6,944 KB |
コンパイルメッセージ
main.c: In function 'hashf': main.c:26:20: warning: implicit declaration of function 'memcmp' [-Wimplicit-function-declaration] 26 | if(memcmp(hashtbl[h],s,p-s)==0 && hashtbl[h][p-s]<64){ | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'memcmp' +++ |+#include <string.h> 1 | #pragma GCC optimize("Ofast") main.c:26:41: warning: 'memcmp' argument 3 type is 'long int' where 'long unsigned int' is expected in a call to built-in function declared without prototype [-Wbuiltin-declaration-mismatch] 26 | if(memcmp(hashtbl[h],s,p-s)==0 && hashtbl[h][p-s]<64){ | ~^~ <built-in>: note: built-in 'memcmp' declared here main.c: At top level: main.c:35:1: warning: return type defaults to 'int' [-Wimplicit-int] 35 | main(){ | ^~~~ main.c: In function 'main': main.c:36:17: warning: implicit declaration of function 'time' [-Wimplicit-function-declaration] 36 | hashmul=time(0)|1; | ^~~~ main.c:1:1: note: 'time' is defined in header '<time.h>'; did you forget to '#include <time.h>'? +++ |+#include <time.h> 1 | #pragma GCC optimize("Ofast") main.c:53:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration] 53 | write(1,wbuf,wp-wbuf); | ^~~~~ main.c:54:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration] 54 | _exit(0); | ^~~~~ | _Exit
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") char*mmap(); char wbuf[20<<20]; #define HASHSIZE (1<<20) char* hashtbl[HASHSIZE]; int hashmul; int hashf(char*s){ int h=0; char*p=s; while(*p>=64){ h=h*hashmul+*p; ++p; } int a=h>>20|1; h&=HASHSIZE-1; while(1){ if(!hashtbl[h]){ hashtbl[h]=s; return 1; } if(memcmp(hashtbl[h],s,p-s)==0 && hashtbl[h][p-s]<64){ return 0; } h=h+a&HASHSIZE-1; } } char*bs[200000]; main(){ hashmul=time(0)|1; char*rp=mmap(0l,1l<<28,1,2,0,0ll); while(*rp++!=10); int n=0; do{ hashf(rp); while(*rp++>=64); bs[n++]=rp; while(*rp++>=64); }while(*rp); char*wp=wbuf; for(int i=0;i<n;++i){ char*p=bs[i]; if(hashf(p)){ while((*wp++=*p++)>=64); } } write(1,wbuf,wp-wbuf); _exit(0); }