結果
| 問題 | No.2616 中央番目の中央値 |
| コンテスト | |
| ユーザー |
👑 tails
|
| 提出日時 | 2024-01-29 10:30:25 |
| 言語 | C90 (gcc 15.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,395 bytes |
| 記録 | |
| コンパイル時間 | 199 ms |
| コンパイル使用メモリ | 26,932 KB |
| 最終ジャッジ日時 | 2026-02-24 01:17:40 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.c:13:1: error: C++ style comments are not allowed in ISO C90
13 | // fenwick
| ^
main.c:13:1: note: (this will be reported only once per input file)
main.c:18:14: error: expected ';' before 'void'
18 | static inline
| ^
| ;
19 | void fw_add(int a,int v){
| ~~~~
main.c:27:14: error: expected ';' before 'int'
27 | static inline
| ^
| ;
28 | int fw_get(int a){
| ~~~
main.c: In function 'mkfac':
main.c:58:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
58 | for(long i=1;i<M;i++){
| ^~~
main.c:58:9: note: use option '-std=c99', '-std=gnu99', '-std=c11' or '-std=gnu11' to compile your code
main.c:63:18: error: redefinition of 'i'
63 | for(long i=M;i--;){
| ^
main.c:58:18: note: previous definition of 'i' with type 'long int'
58 | for(long i=1;i<M;i++){
| ^
main.c:63:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
63 | for(long i=M;i--;){
| ^~~
main.c: At top level:
main.c:69:8: error: unknown type name 'inline'
69 | static inline
| ^~~~~~
main.c:70:7: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'binom'
70 | ulong binom(int a,int b){
| ^~~~~
main.c: In function 'main':
main.c:81:13: error: expected ';' before 'i'
81 | rep(i,n){
| ^
main.c:8:32: note: in definition of macro 'rep'
8 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
| ^
main.c:81:13: error: 'i' undeclared (first use in this function)
81 | rep(i,n){
| ^
main.c:8:36: note: in definition of macro 'rep'
8 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
| ^
main.c:81:13: note: each undeclared identifier is reported only on
ソースコード
#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 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)
#define MD 998244353
typedef unsigned long ulong;
// fenwick
#define FWSIZE (1<<20)
int fw[FWSIZE];
static inline
void fw_add(int a,int v){
if(a==0){
fw[0]+=v;
}else{
while(fw[a]+=v,a+=a&-a,a<FWSIZE);
}
}
static inline
int fw_get(int a){
int z=0;
while(z+=fw[a],a)a-=a&-a;
return z;
}
// fac table
#define M 300001
unsigned fac[M],ifac[M];
int inverse(int a){
int b=MD;
int u=1;
int v=0;
int s,t;
while(b){
t=a/b;
s=b; b=a-t*b; a=s;
s=v; v=u-t*v; u=s;
}
if(u<0){
u+=MD;
}
return u;
}
void mkfac(){
ulong x=1;
fac[0]=x;
for(long i=1;i<M;i++){
x=x*i%MD;
fac[i]=x;
}
x=inverse(x);
for(long i=M;i--;){
ifac[i]=x;
x=x*i%MD;
}
}
static inline
ulong binom(int a,int b){
return (ulong)fac[a+b]*ifac[a]%MD*ifac[b]%MD;
}
// main
int main(){
mkfac();
rd_init();
ulong z=0;
int n=rd();
rep(i,n){
int p=rd()-1;
int a=fw_get(p);
int b=i-a;
int c=p-a;
int d=n-1-a-b-c;
z=(z+binom(a,d)*binom(b,c))%MD;
fw_add(p,1);
}
wt1(z);
_exit(0);
}
tails