提出 #49183824


ソースコード 拡げる

#include<bits/stdc++.h>
#include<atcoder/convolution>
#include<atcoder/modint>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef atcoder::modint998244353 mint;
typedef vector<mint> poly;

#define rep(i,l,r) for(int i(l);i<=(r);++i)
#define per(i,r,l) for(int i(r);i>=(l);--i)
#define eb emplace_back
#define File(filename) freopen(filename ".in","r",stdin),freopen(filename ".out","w",stdout)

#ifdef EXODUS
	#define Debug(...) fprintf(stderr,__VA_ARGS__)
#else
	#define Debug(...) 0
#endif

//=========================================================================================================
// Something about IO

template<typename T>
void read(T &x){
	x=0;T flg=1;
	char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')flg=-1;ch=getchar();}
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	x*=flg;
}
template<typename T,typename... Args>
void read(T &x,Args &...args){read(x),read(args...);}

//=========================================================================================================
// Define the global variables here.

bool membg=0;

constexpr int N=2e5+7;
int n;
int d[N];
mint fac[N];

bool memed=0;

//=========================================================================================================
// Code here.

poly solve(int l,int r){
	if(l==r)return poly{1,d[l]};
	int mid=(l+r)>>1;
	return atcoder::convolution(solve(l,mid),solve(mid+1,r));
}

void solve(){
	read(n);
	for(int i=1;i<=n;i++)read(d[i]);
	fac[0]=1;for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i;
	mint ans=fac[n-1];
	auto F=solve(1,n);
	mint base=1;
	for(int i=1;i<n;i++){
		ans+=fac[n-i]*F[i]*base;
		base*=n;
	}
	ans/=n;
	for(int i=1;i<=n;i++)ans/=fac[d[i]];
	printf("%d\n",ans.val());
	return;
}


//=========================================================================================================

int main(){
	Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
	int timbg=clock();
	int T=1;
	while(T--)solve();
	int timed=clock();
	Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
	fflush(stdout);
	return 0;
}

提出情報

提出日時
問題 F - Directable as Desired
ユーザ EXODUS
言語 C++ 20 (gcc 12.2)
得点 1000
コード長 2205 Byte
結果 AC
実行時間 148 ms
メモリ 9664 KiB

コンパイルエラー

Main.cpp: In function ‘int main()’:
Main.cpp:21:28: warning: statement has no effect [-Wunused-value]
   21 |         #define Debug(...) 0
      |                            ^
Main.cpp:80:9: note: in expansion of macro ‘Debug’
   80 |         Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
      |         ^~~~~
Main.cpp:21:28: warning: statement has no effect [-Wunused-value]
   21 |         #define Debug(...) 0
      |                            ^
Main.cpp:85:9: note: in expansion of macro ‘Debug’
   85 |         Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
      |         ^~~~~
Main.cpp:81:13: warning: unused variable ‘timbg’ [-Wunused-variable]
   81 |         int timbg=clock();
      |             ^~~~~
Main.cpp:84:13: warning: unused variable ‘timed’ [-Wunused-variable]
   84 |         int timed=clock();
      |             ^~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 1000 / 1000
結果
AC × 3
AC × 39
セット名 テストケース
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_rand_01.txt, 01_rand_02.txt, 01_rand_03.txt, 01_rand_04.txt, 01_rand_05.txt, 01_rand_06.txt, 01_rand_07.txt, 01_rand_08.txt, 01_rand_09.txt, 01_rand_10.txt, 01_rand_11.txt, 01_rand_12.txt, 01_rand_13.txt, 01_rand_14.txt, 01_rand_15.txt, 01_rand_16.txt, 01_rand_17.txt, 01_rand_18.txt, 01_rand_19.txt, 01_rand_20.txt, 02_maxi_01.txt, 02_maxi_02.txt, 02_maxi_03.txt, 02_maxi_04.txt, 02_maxi_05.txt, 02_maxi_06.txt, 02_maxi_07.txt, 02_maxi_08.txt, 02_maxi_09.txt, 02_maxi_10.txt, 03_test_01.txt, 03_test_02.txt, 03_test_03.txt, 03_test_04.txt, 03_test_05.txt, 03_test_06.txt
ケース名 結果 実行時間 メモリ
00_sample_01.txt AC 1 ms 4548 KiB
00_sample_02.txt AC 1 ms 4412 KiB
00_sample_03.txt AC 1 ms 4588 KiB
01_rand_01.txt AC 141 ms 9412 KiB
01_rand_02.txt AC 132 ms 9384 KiB
01_rand_03.txt AC 140 ms 9368 KiB
01_rand_04.txt AC 142 ms 9460 KiB
01_rand_05.txt AC 137 ms 9360 KiB
01_rand_06.txt AC 132 ms 9472 KiB
01_rand_07.txt AC 147 ms 9476 KiB
01_rand_08.txt AC 77 ms 6912 KiB
01_rand_09.txt AC 77 ms 6876 KiB
01_rand_10.txt AC 143 ms 9440 KiB
01_rand_11.txt AC 131 ms 9484 KiB
01_rand_12.txt AC 130 ms 9256 KiB
01_rand_13.txt AC 74 ms 6808 KiB
01_rand_14.txt AC 73 ms 6656 KiB
01_rand_15.txt AC 133 ms 9304 KiB
01_rand_16.txt AC 131 ms 9348 KiB
01_rand_17.txt AC 127 ms 9204 KiB
01_rand_18.txt AC 73 ms 6772 KiB
01_rand_19.txt AC 75 ms 6776 KiB
01_rand_20.txt AC 129 ms 9328 KiB
02_maxi_01.txt AC 148 ms 9664 KiB
02_maxi_02.txt AC 148 ms 9492 KiB
02_maxi_03.txt AC 148 ms 9496 KiB
02_maxi_04.txt AC 148 ms 9492 KiB
02_maxi_05.txt AC 147 ms 9464 KiB
02_maxi_06.txt AC 148 ms 9528 KiB
02_maxi_07.txt AC 147 ms 9556 KiB
02_maxi_08.txt AC 147 ms 9492 KiB
02_maxi_09.txt AC 148 ms 9496 KiB
02_maxi_10.txt AC 148 ms 9456 KiB
03_test_01.txt AC 1 ms 4580 KiB
03_test_02.txt AC 147 ms 9528 KiB
03_test_03.txt AC 147 ms 9480 KiB
03_test_04.txt AC 148 ms 9496 KiB
03_test_05.txt AC 147 ms 9540 KiB
03_test_06.txt AC 148 ms 9532 KiB