結果
問題 |
No.1630 Sorting Integers (Greater than K)
|
ユーザー |
![]() |
提出日時 | 2021-07-31 07:59:46 |
言語 | C (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,106 bytes |
コンパイル時間 | 396 ms |
コンパイル使用メモリ | 32,896 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-16 09:07:55 |
合計ジャッジ時間 | 1,521 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 WA * 1 |
other | AC * 20 WA * 2 |
コンパイルメッセージ
main.c:12:1: warning: return type defaults to 'int' [-Wimplicit-int] 12 | main(){ | ^~~~ main.c: In function 'main': main.c:17:19: warning: initialization of 'char *' from 'long int' makes pointer from integer without a cast [-Wint-conversion] 17 | char*klen=rp-kp-1; | ^~ main.c:23:16: warning: comparison between pointer and integer 23 | if(klen>n){ | ^ main.c:24:17: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration] 24 | write(1,"-1",2); | ^~~~~ main.c:25:17: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration] 25 | _exit(0); | ^~~~~ | _Exit main.c:27:16: warning: comparison between pointer and integer 27 | if(klen<n){ | ^ main.c:30:25: warning: implicit declaration of function 'memset' [-Wimplicit-function-declaration] 30 | memset(wp,i+'1',c[i]); | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'memset' +++ |+#include <string.h> 1 | #pragma GCC optimize("Ofast") main.c:30:25: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch] 30 | memset(wp,i+'1',c[i]); | ^~~~~~ main.c:30:25: note: include '<string.h>' or provide a declaration of 'memset' main.c:71:25: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch] 71 | memset(wp,i+'1',c[i]); | ^~~~~~ main.c:71:25: note: include '<string.h>' or provide a declaration of 'memset'
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") char*mmap(); char wbuf[1<<25]; #define rd_skip() while(*rp++>=48) #define rd(v) long v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} #define rep(v,e) for(long v=0;v<e;++v) #define chmax(v,a) (v=v>=a?v:a) main(){ char*rp=mmap(0l,1l<<25,1,2,0,0ll); rd(n); char*kp=rp; rd_skip(); char*klen=rp-kp-1; long c[9]; rep(i,9){ rd(ci); c[i]=ci; } if(klen>n){ write(1,"-1",2); _exit(0); } if(klen<n){ char*wp=wbuf; rep(i,9){ memset(wp,i+'1',c[i]); wp+=c[i]; } write(1,wbuf,wp-wbuf); _exit(0); } { char*wp=wbuf; long d=0; while(d<n&&c[kp[d]-'1']){ --c[kp[d]-'1']; *wp++=kp[d++]; } long imax=0; rep(i,9){ if(c[i]){ imax=i; } } if(d==n){ --d; ++c[*--wp-'1']; } while(d>=0&&imax<=kp[d]-'1'){ chmax(imax,kp[d]-'1'); --d; ++c[*--wp-'1']; } if(d<0){ write(1,"-1",2); _exit(0); } { long i=kp[d]+1-'1'; while(!c[i]){ ++i; } *wp++=i+'1'; --c[i]; } rep(i,9){ memset(wp,i+'1',c[i]); wp+=c[i]; } write(1,wbuf,wp-wbuf); _exit(0); } }