Submission #1331307
Source Code Expand
#include<bits/stdc++.h> using namespace std; int d[333][333][333],n,m; #define mod 1000000007 int add(int x,int y){ return (x+=y)<mod?x:x-mod; } int mul(int x,int y){ return (int)((long long int)x*y%mod); } void addto(int&x,int y){ x = add(x,y); } int main(){ scanf("%d%d",&n,&m); d[0][1][0] = 1; for(int i=0; i<m; i++) for(int j=1; j<=i+1 && j<=n; j++) for(int k=0; j+k<=n; k++){ if(d[i][j][k]==0)continue; addto(d[i+1][j+k][0],mul(d[i][j][k],j)); addto(d[i+1][j][k],mul(d[i][j][k],k)); if(j+k<n) addto(d[i+1][j][k+1],mul(d[i][j][k],n-j-k)); } printf("%d\n",d[m][n][0]); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Road of the King |
User | maryanna2016 |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 633 Byte |
Status | AC |
Exec Time | 72 ms |
Memory | 128384 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:15:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d",&n,&m); ^
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, sample-01.txt, sample-02.txt, sample-03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 1 ms | 256 KB |
01-02.txt | AC | 1 ms | 256 KB |
01-03.txt | AC | 26 ms | 127232 KB |
01-04.txt | AC | 1 ms | 256 KB |
01-05.txt | AC | 26 ms | 127232 KB |
01-06.txt | AC | 35 ms | 127616 KB |
01-07.txt | AC | 71 ms | 128000 KB |
01-08.txt | AC | 72 ms | 128384 KB |
01-09.txt | AC | 72 ms | 128384 KB |
01-10.txt | AC | 72 ms | 128384 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 48 ms | 127872 KB |
sample-03.txt | AC | 21 ms | 63744 KB |