提出 #20215347


ソースコード 拡げる

#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define mod 998244353
struct modint{
    int x;
    modint(int o=0){x=o;}
    modint &operator = (int o){return x=o,*this;}
    modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}
    modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}
    modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}
    modint &operator ^=(int b){
        modint a=*this,c=1;
        for(;b;b>>=1,a*=a)if(b&1)c*=a;
        return x=c.x,*this;
    }
    modint &operator /=(modint o){return *this *=o^=mod-2;}
    modint &operator +=(int o){return x=x+o>=mod?x+o-mod:x+o,*this;}
    modint &operator -=(int o){return x=x-o<0?x-o+mod:x-o,*this;}
    modint &operator *=(int o){return x=1ll*x*o%mod,*this;}
    modint &operator /=(int o){return *this *= ((modint(o))^=mod-2);}
    template<class I>friend modint operator +(modint a,I b){return a+=b;}
    template<class I>friend modint operator -(modint a,I b){return a-=b;}
    template<class I>friend modint operator *(modint a,I b){return a*=b;}
    template<class I>friend modint operator /(modint a,I b){return a/=b;}
    friend modint operator ^(modint a,int b){return a^=b;}
    friend bool operator ==(modint a,int b){return a.x==b;}
    friend bool operator !=(modint a,int b){return a.x!=b;}
    bool operator ! () {return !x;}
    modint operator - () {return x?mod-x:0;}
};
#define maxn 3003
int n,m,a[maxn];
modint C[maxn][maxn],f[maxn][maxn];
signed main()
{
	n=read(),m=read();
	For(i,1,n)a[i]=read();
	For(i,0,n)C[i][0]=1;
	For(i,1,n)For(j,1,i)C[i][j]=C[i-1][j-1]+C[i-1][j];
	f[0][0]=1;
	For(i,0,m-1)
		For(j,0,n){
			f[i+1][j]+=f[i][j]*2*j;
			f[i+1][j+1]+=f[i][j];
		}
	modint res=0;
	For(l,0,n)
		Rep(r,n-l,0){
			if(n-l-r>=2&&a[n-r-1]>a[n-r])break;
			res+=C[l+r][l]*f[m][l+r];
		}
	cout<<res.x;
	return 0;
}

提出情報

提出日時
問題 E - Cigar Box
ユーザ Rainbow_sjy
言語 C++ (GCC 9.2.1)
得点 700
コード長 2204 Byte
結果 AC
実行時間 137 ms
メモリ 74084 KiB

コンパイルエラー

./Main.cpp: In function ‘int read()’:
./Main.cpp:10:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
   10 |     if(f)x=-x;return x;
      |     ^~
./Main.cpp:10:15: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
   10 |     if(f)x=-x;return x;
      |               ^~~~~~
./Main.cpp: In function ‘int main()’:
./Main.cpp:47:6: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   47 |  For(i,1,n)a[i]=read();
      |      ^
./Main.cpp:2:37: note: in definition of macro ‘For’
    2 | #define For(i,a,b) for(register int i=(a);i<=(b);++i)
      |                                     ^
./Main.cpp:48:6: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   48 |  For(i,0,n)C[i][0]=1;
      |      ^
./Main.cpp:2:37: note: in definition of macro ‘For’
    2 | #define For(i,a,b) for(register int i=(a);i<=(b);++i)
      |                                     ^
./Main.cpp:49:6: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   49 |  For(i,1,n)For(j,1,i)C[i][j]=C[i-1][j-1]+C[i-1][j];
      |      ^
./Main.cpp:2:37: note: in definition of macro ‘For’
    2 | #define For(i,a,b) for(register int i=(a);i<=(b);++i)
      |                                     ^
./Main.cpp:49:16: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   49 |  For(i,1,n)For(j,1,i)C[i][j]=C[i-1][j-1]+C[i-1][j];
      |                ^
./Main.cpp:2:37: note: in definition of macro ‘For’
    2 | #define For(i,a,b) for(register int i=(a);i<=(b);++i)
      |                                     ^
./Main.cpp:51:6: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   51 |  For(i,0,m-1)
      |      ^
./Main.cpp:2:37: note: in definition of macro ‘For’
    2 | #define For(i,a,b) for(register int i=(a);i<=(b);++i)
      |                                     ^
./Main.cpp:52:7: w...

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 700 / 700
結果
AC × 3
AC × 36
セット名 テストケース
Sample sample.txt, sample_2.txt, sample_3.txt
All dec_1097_1362.txt, dec_1214_138.txt, dec_2404_801.txt, dec_2886_2657.txt, dec_754_2194.txt, inc_2393_1050.txt, inc_2728_537.txt, inc_325_982.txt, inc_728_2645.txt, inc_786_1704.txt, random_102_2522.txt, random_1326_1061.txt, random_1421_916.txt, random_146_5.txt, random_1559_262.txt, random_16_157.txt, random_1775_2266.txt, random_2015_811.txt, random_20_1776.txt, random_222_41.txt, random_27_10.txt, random_2993_1514.txt, random_2_4.txt, random_333_1061.txt, random_360_208.txt, random_4_23.txt, random_501_2539.txt, random_781_1616.txt, random_7_203.txt, random_89_890.txt, sample.txt, sample_2.txt, sample_3.txt, sorted_3000_1.txt, sorted_3000_300.txt, sorted_3000_3000.txt
ケース名 結果 実行時間 メモリ
dec_1097_1362.txt AC 62 ms 73892 KiB
dec_1214_138.txt AC 56 ms 74072 KiB
dec_2404_801.txt AC 64 ms 74076 KiB
dec_2886_2657.txt AC 87 ms 73892 KiB
dec_754_2194.txt AC 60 ms 73996 KiB
inc_2393_1050.txt AC 76 ms 73984 KiB
inc_2728_537.txt AC 79 ms 74000 KiB
inc_325_982.txt AC 54 ms 74084 KiB
inc_728_2645.txt AC 63 ms 74032 KiB
inc_786_1704.txt AC 65 ms 74084 KiB
random_102_2522.txt AC 58 ms 73976 KiB
random_1326_1061.txt AC 64 ms 73996 KiB
random_1421_916.txt AC 62 ms 73916 KiB
random_146_5.txt AC 55 ms 73908 KiB
random_1559_262.txt AC 57 ms 74032 KiB
random_16_157.txt AC 57 ms 74084 KiB
random_1775_2266.txt AC 69 ms 73864 KiB
random_2015_811.txt AC 62 ms 74024 KiB
random_20_1776.txt AC 55 ms 73992 KiB
random_222_41.txt AC 57 ms 74036 KiB
random_27_10.txt AC 49 ms 73976 KiB
random_2993_1514.txt AC 77 ms 74004 KiB
random_2_4.txt AC 52 ms 73888 KiB
random_333_1061.txt AC 57 ms 73968 KiB
random_360_208.txt AC 51 ms 74064 KiB
random_4_23.txt AC 48 ms 73976 KiB
random_501_2539.txt AC 58 ms 73884 KiB
random_781_1616.txt AC 64 ms 74028 KiB
random_7_203.txt AC 50 ms 74012 KiB
random_89_890.txt AC 55 ms 74012 KiB
sample.txt AC 53 ms 74028 KiB
sample_2.txt AC 56 ms 74080 KiB
sample_3.txt AC 58 ms 74084 KiB
sorted_3000_1.txt AC 103 ms 73868 KiB
sorted_3000_300.txt AC 112 ms 73900 KiB
sorted_3000_3000.txt AC 137 ms 73888 KiB