結果
| 問題 | No.938 賢人を探せ |
| コンテスト | |
| ユーザー |
👑 tails
|
| 提出日時 | 2021-01-19 09:23:21 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 2,000 ms |
| コード長 | 776 bytes |
| 記録 | |
| コンパイル時間 | 999 ms |
| コンパイル使用メモリ | 30,720 KB |
| 実行使用メモリ | 10,368 KB |
| 最終ジャッジ日時 | 2024-12-16 00:35:33 |
| 合計ジャッジ時間 | 1,558 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
コンパイルメッセージ
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);
}
tails