結果
問題 | No.1909 Detect from Substrings |
ユーザー | tails |
提出日時 | 2022-04-22 23:04:21 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,467 bytes |
コンパイル時間 | 314 ms |
コンパイル使用メモリ | 30,976 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 04:27:01 |
合計ジャッジ時間 | 1,817 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,944 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | AC | 1 ms
6,940 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 1 ms
6,944 KB |
testcase_08 | AC | 1 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 1 ms
6,944 KB |
testcase_11 | AC | 1 ms
6,940 KB |
testcase_12 | AC | 1 ms
6,944 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 1 ms
6,940 KB |
testcase_15 | AC | 1 ms
6,944 KB |
testcase_16 | AC | 1 ms
6,940 KB |
testcase_17 | AC | 1 ms
6,940 KB |
testcase_18 | AC | 1 ms
6,940 KB |
testcase_19 | AC | 1 ms
6,940 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 1 ms
6,940 KB |
testcase_22 | AC | 1 ms
6,940 KB |
testcase_23 | AC | 2 ms
6,940 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 2 ms
6,940 KB |
testcase_26 | AC | 2 ms
6,944 KB |
testcase_27 | AC | 1 ms
6,944 KB |
testcase_28 | AC | 2 ms
6,944 KB |
testcase_29 | AC | 1 ms
6,940 KB |
testcase_30 | AC | 1 ms
6,944 KB |
testcase_31 | AC | 2 ms
6,940 KB |
testcase_32 | AC | 1 ms
6,944 KB |
testcase_33 | AC | 1 ms
6,940 KB |
testcase_34 | AC | 1 ms
6,940 KB |
testcase_35 | AC | 1 ms
6,940 KB |
testcase_36 | AC | 1 ms
6,944 KB |
testcase_37 | AC | 1 ms
6,940 KB |
testcase_38 | AC | 1 ms
6,940 KB |
コンパイルメッセージ
main.c: In function 'main': main.c:57:17: warning: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration] 57 | memcpy(t+(j+1),s2+j,m-j); | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'memcpy' +++ |+#include <string.h> 1 | #pragma GCC optimize("Ofast") main.c:57:17: warning: incompatible implicit declaration of built-in function 'memcpy' [-Wbuiltin-declaration-mismatch] 57 | memcpy(t+(j+1),s2+j,m-j); | ^~~~~~ main.c:57:17: note: include '<string.h>' or provide a declaration of 'memcpy' main.c:62:17: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration] 62 | write(1,&r,1); | ^~~~~ main.c:89:28: warning: implicit declaration of function 'memcmp' [-Wimplicit-function-declaration] 89 | r+=memcmp(s1+j,s2+(j+1),k-j)==0; | ^~~~~~ main.c:89:28: note: include '<string.h>' or provide a declaration of 'memcmp' main.c:89:50: 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] 89 | r+=memcmp(s1+j,s2+(j+1),k-j)==0; | ~^~ <built-in>: note: built-in 'memcmp' declared here main.c:90:50: 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] 90 | r+=memcmp(s1+(j+1),s2+j,k-j)==0; | ~^~ <built-in>: note: built-in 'memcmp' declared here main.c:94:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration] 94 | _exit(0); | ^~~~~ | _Exi
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rd_skip() while(*rp++>=48) #define rd() ({long _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;}) char t[500004]; long f(char*s){ while(*s){ char*u=t; while(*(long*)s==*(long*)u){ s+=sizeof(long); u+=sizeof(long); } while(*s==*u){ ++s; ++u; } ++u; while(*(long*)s==*(long*)u){ s+=sizeof(long); u+=sizeof(long); } while(*s==*u){ ++s; ++u; } if(*s++!=10){ return 0; } } return 1; } int main(){ char*mmap(); char*rp=mmap(0l,1l<<25,1,2,0,0ll); rd_skip(); long m=rd(); if(rp[m*2+2]){ // case: n != 2 long j=0; char*s1=rp; char*s2=rp+(m+1); long v; while(v=*(long*)(s1+j),v==*(long*)(s2+j)){ *(long*)(t+j)=v; j+=sizeof(long); } while(s1[j]==s2[j]){ t[j]=s1[j]; ++j; } long r=48; t[j]=s1[j]; memcpy(t+(j+1),s2+j,m-j); r+=f(rp); t[j]=s2[j]; memcpy(t+(j+1),s1+j,m-j); r+=f(rp); write(1,&r,1); } else{ // case: n == 2 long j=0,k=m-1; char*s1=rp; char*s2=rp+(m+1); while(*(long*)(s1+j)==*(long*)(s2+j)){ j+=sizeof(long); } while(s1[j]==s2[j]){ ++j; } if(m>=sizeof(long)){ while(*(long*)(s1+(k-(sizeof(long)-1)))==*(long*)(s2+(k-(sizeof(long)-1)))){ k-=sizeof(long); } } while(s1[k]==s2[k]){ --k; } long r; if(j==k){ r='2'; } else{ r=48; r+=memcmp(s1+j,s2+(j+1),k-j)==0; r+=memcmp(s1+(j+1),s2+j,k-j)==0; } write(1,&r,1); } _exit(0); }