Submission #993430
Source Code Expand
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
using namespace std;
#ifdef DEB
#define dump(x) cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif
template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;
namespace std{
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
out<<'('<<a.fr<<','<<a.sc<<')';
return out;
}
}
lint readL(){
lint res;
#ifdef ONLINE_JUDGE
scanf("%I64d",&res);
#else
scanf("%lld",&res);
#endif
return res;
}
void printL(lint res){
#ifdef ONLINE_JUDGE
printf("%I64d",res);
#else
printf("%lld",res);
#endif
}
template<lint mod>
struct Int_{
unsigned x;
unsigned mpow(Int_ a,unsigned k){
Int_ res=1;
while(k){
if(k&1) res=res*a;
a=a*a;
k>>=1;
}
return res.x;
}
unsigned inverse(Int_ a){
return mpow(a,mod-2);
}
Int_(): x(0) { }
Int_(long long sig) {
int sigt=sig%mod;
if(sigt<0) sigt+=mod;
x=sigt;
}
unsigned get() const { return (unsigned)x; }
Int_ &operator+=(Int_ that) { if((x += that.x) >= mod) x -= mod; return *this; }
Int_ &operator-=(Int_ that) { if((x += mod - that.x) >= mod) x -= mod; return *this; }
Int_ &operator*=(Int_ that) { x = (unsigned long long)x * that.x % mod; return *this; }
Int_ &operator=(Int_ that) { x=that.x; return *this;}
Int_ &operator/=(Int_ that) { x=(unsigned long long) x * inverse(that.x)%mod; return *this;}
bool operator==(Int_ that) const { return x==that.x; }
bool operator!=(Int_ that) const { return x!=that.x; }
Int_ operator-() const { return Int_(0)-Int_(*this);}
Int_ operator+(Int_ that) const { return Int_(*this) += that; }
Int_ operator-(Int_ that) const { return Int_(*this) -= that; }
Int_ operator*(Int_ that) const { return Int_(*this) *= that; }
Int_ operator/(Int_ that) const { return Int_(*this) /= that; }
};
namespace std{
template<lint mod>
ostream &operator <<(ostream& out,const Int_<mod>& a){
out<<a.get();
return out;
}
template<lint mod>
istream &operator >>(istream& in,Int_<mod>& a){
in>>a.x;
return in;
}
};
typedef Int_<1000000007> Int;
//const int INF=5e8;
int n,m;
Int dp[305][305][305];
Int mpow(Int a,int k){
Int res=1;
while(k){
if(k&1) res=res*a;
a=a*a;
k>>=1;
}
return res;
}
int main(){
cin>>n>>m;
dp[1][1][1]=1;
for(int i=1;i<=m+1;++i) for(int j=0;j<=i;++j) for(int k=0;k<=i;++k){
Int val=dp[i][j][k];
dp[i+1][j][k+1]+=val*(n-k);
dp[i+1][j][k]+=val*max(0,(k-j));
dp[i+1][k][k]+=val*j;
}
Int res=dp[m+1][n][n];
cout<<res<<endl;
return 0;
}
Submission Info
Submission Time
2016-11-26 13:53:01+0900
Task
F - Road of the King
User
hogloid
Language
C++14 (GCC 5.4.1)
Score
1000
Code Size
3549 Byte
Status
AC
Exec Time
234 ms
Memory
111104 KB
Compile Error
./Main.cpp: In function ‘lint readL()’:
./Main.cpp:49:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&res);
^
Judge Result
Set Name
sample
all
Score / Max Score
0 / 0
1000 / 1000
Status
Set Name
Test Cases
sample
sample-01.txt, sample-02.txt, sample-03.txt
all
sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt
Case Name
Status
Exec Time
Memory
01-01.txt
AC
102 ms
111104 KB
01-02.txt
AC
102 ms
111104 KB
01-03.txt
AC
187 ms
111104 KB
01-04.txt
AC
102 ms
111104 KB
01-05.txt
AC
188 ms
111104 KB
01-06.txt
AC
197 ms
111104 KB
01-07.txt
AC
231 ms
111104 KB
01-08.txt
AC
233 ms
111104 KB
01-09.txt
AC
232 ms
111104 KB
01-10.txt
AC
234 ms
111104 KB
sample-01.txt
AC
102 ms
111104 KB
sample-02.txt
AC
210 ms
111104 KB
sample-03.txt
AC
120 ms
111104 KB