結果
問題 | No.2769 Number of Rhombi |
ユーザー | tails |
提出日時 | 2024-06-03 22:45:50 |
言語 | C90 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 78 ms / 5,000 ms |
コード長 | 3,160 bytes |
コンパイル時間 | 1,021 ms |
コンパイル使用メモリ | 29,056 KB |
実行使用メモリ | 12,928 KB |
最終ジャッジ日時 | 2024-06-03 22:45:56 |
合計ジャッジ時間 | 4,553 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 0 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 54 ms
12,928 KB |
testcase_04 | AC | 47 ms
11,904 KB |
testcase_05 | AC | 37 ms
8,448 KB |
testcase_06 | AC | 50 ms
10,624 KB |
testcase_07 | AC | 59 ms
12,800 KB |
testcase_08 | AC | 61 ms
12,800 KB |
testcase_09 | AC | 67 ms
12,800 KB |
testcase_10 | AC | 62 ms
12,800 KB |
testcase_11 | AC | 64 ms
12,928 KB |
testcase_12 | AC | 65 ms
12,800 KB |
testcase_13 | AC | 66 ms
12,800 KB |
testcase_14 | AC | 68 ms
12,800 KB |
testcase_15 | AC | 72 ms
12,800 KB |
testcase_16 | AC | 69 ms
12,800 KB |
testcase_17 | AC | 70 ms
12,800 KB |
testcase_18 | AC | 72 ms
12,928 KB |
testcase_19 | AC | 71 ms
12,800 KB |
testcase_20 | AC | 72 ms
12,928 KB |
testcase_21 | AC | 72 ms
12,800 KB |
testcase_22 | AC | 71 ms
12,800 KB |
testcase_23 | AC | 78 ms
12,800 KB |
testcase_24 | AC | 1 ms
5,376 KB |
testcase_25 | AC | 64 ms
12,800 KB |
testcase_26 | AC | 66 ms
12,800 KB |
testcase_27 | AC | 68 ms
12,928 KB |
testcase_28 | AC | 68 ms
12,800 KB |
testcase_29 | AC | 72 ms
12,928 KB |
testcase_30 | AC | 66 ms
12,800 KB |
testcase_31 | AC | 64 ms
12,800 KB |
testcase_32 | AC | 61 ms
12,928 KB |
testcase_33 | AC | 61 ms
12,928 KB |
testcase_34 | AC | 63 ms
12,928 KB |
コンパイルメッセージ
main.c: In function ‘main’: main.c:8:59: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration] 8 | #define wt1(v) ({char wbuf[64],*wp=wbuf+sizeof wbuf;wt(v);write(1,wp,wbuf+sizeof wbuf-wp);}) | ^~~~~ main.c:164:9: note: in expansion of macro ‘wt1’ 164 | wt1(z); | ^~~ main.c:165:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration] 165 | _exit(0); | ^~~~~ main.c:165:9: warning: incompatible implicit declaration of built-in function ‘_exit’ [-Wbuiltin-declaration-mismatch]
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);}) #define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;}) #define rd_signed() ({long _s=*rp=='-'&&++rp,_v=rd();_s?-_v:_v;}) #define wt(v) ({unsigned _z=v;do*--wp=_z%10+48;while(_z/=10);}) #define wt1(v) ({char wbuf[64],*wp=wbuf+sizeof wbuf;wt(v);write(1,wp,wbuf+sizeof wbuf-wp);}) #define rep(v,e) for(typeof(e) v=0;v<e;++v) typedef unsigned long ulong; int n; struct{int x,y;}xy[1000]; struct cd{ulong c,d;}cd1[500000],cd2[500000],cdbuf[500000]; int cd1n,cd2n; void sort_aux1(struct cd*a,struct cd*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].d&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){ int k=c[a[i].d&255]++; b[k].c=a[i].c; b[k].d=a[i].d>>8|a[i].d<<56; } } void sort_aux2(struct cd*a,struct cd*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].c&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){ int k=c[a[i].c&255]++; b[k].c=a[i].c>>8|a[i].c<<56; b[k].d=a[i].d; } } void sort(struct cd*a,int n){ struct cd*b=cdbuf; sort_aux1(a,b,n); sort_aux1(b,a,n); sort_aux1(a,b,n); sort_aux1(b,a,n); sort_aux1(a,b,n); sort_aux1(b,a,n); sort_aux1(a,b,n); sort_aux1(b,a,n); sort_aux2(a,b,n); sort_aux2(b,a,n); sort_aux2(a,b,n); sort_aux2(b,a,n); sort_aux2(a,b,n); sort_aux2(b,a,n); sort_aux2(a,b,n); sort_aux2(b,a,n); } static inline int gcd(int a,int b){ int x=__builtin_ctz(a); int y=__builtin_ctz(b); a>>=x; b>>=y; for(int c;c=a-b;){ c>>=__builtin_ctz(c); if(c<0){ b=-c; }else{ a=c; } } return a<<(x<=y?x:y); } int main(){ rd_init(); n=rd(); rep(i,n){ xy[i].x=rd_signed(); xy[i].y=rd_signed(); rep(j,i){ int cx=xy[i].x+xy[j].x; int cy=xy[i].y+xy[j].y; ulong c=(ulong)(unsigned)cy<<32|(ulong)(unsigned)cx; int dx=xy[i].x-xy[j].x; int dy=xy[i].y-xy[j].y; if(dy==0){ cd1[cd1n].c=c; cd1[cd1n].d=1; ++cd1n; }else if(dx==0){ cd2[cd2n].c=c; cd2[cd2n].d=1; ++cd2n; }else{ if(dy<0){ dx=-dx; dy=-dy; } if(dx>=0){ unsigned g=gcd(dx,dy); dx/=g; dy/=g; cd1[cd1n].c=c; cd1[cd1n].d=(ulong)(unsigned)dy<<32|(ulong)(unsigned)dx; ++cd1n; }else{ dx=-dx; unsigned g=gcd(dx,dy); dx/=g; dy/=g; cd2[cd2n].c=c; cd2[cd2n].d=(ulong)(unsigned)dx<<32|(ulong)(unsigned)dy; ++cd2n; } } } } sort(cd1,cd1n); sort(cd2,cd2n); --cd1n; --cd2n; int z=0; while(cd1n>=0&&cd2n>=0){ if(cd1[cd1n].c<cd2[cd2n].c||cd1[cd1n].c==cd2[cd2n].c&&cd1[cd1n].d<cd2[cd2n].d){ --cd2n; }else if(cd1[cd1n].c>cd2[cd2n].c||cd1[cd1n].c==cd2[cd2n].c&&cd1[cd1n].d>cd2[cd2n].d){ --cd1n; }else{ int a1=cd1n; while(cd1n>=0&&cd1[cd1n].c==cd1[a1].c&&cd1[cd1n].d==cd1[a1].d){ --cd1n; } int a2=cd2n; while(cd2n>=0&&cd2[cd2n].c==cd2[a2].c&&cd2[cd2n].d==cd2[a2].d){ --cd2n; } z+=(a1-cd1n)*(a2-cd2n); } } wt1(z); _exit(0); }