Submission #1001930


Source Code Expand

            #include <bits/stdc++.h>
            #include<iostream>
            #include<cstdio>
            #include<vector>
            #include<queue>
            #include<map>
            #include<cstring>
            #include<string>
            #include <math.h>
            #include<algorithm>
        //    #include <boost/multiprecision/cpp_int.hpp>
            #include<functional>
          #define int long long
            #define inf  1000000007
            #define pa pair<int,int>
    #define ll long long
            #define pal pair<ll,ll>
            #define ppa pair<int,pa>
            #define  mp make_pair
            #define  pb push_back
            #define EPS (1e-10)
            #define equals(a,b) (fabs((a)-(b))<EPS)
     
            using namespace std;
     
            class Point{
            	public:
            	double x,y;
            	Point(double x=0,double y=0):x(x),y(y) {}
            	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
            	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
            	Point operator * (double a) {return Point(x*a,y*a);}
            	Point operator / (double a) {return Point(x/a,y/a);}
            	double absv() {return sqrt(norm());}
            	double norm() {return x*x+y*y;}
            	bool operator < (const Point &p) const{
            		return x != p.x ? x<p.x: y<p.y;
            	}
            	bool operator == (const Point &p) const{
            		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
            	}
            };
            typedef Point Vector;
     
            struct Segment{
            Point p1,p2;
            };
     
        double hen(Vector a){
        if(fabs(a.x)<EPS && a.y>0) return acos(0);
        else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
        else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
        else if(fabs(a.y)<EPS && a.x>0) return 0.0;
        else if(a.y>0) return acos(a.x/a.absv());
        else return 2*acos(0)+acos(-a.x/a.absv());
     
        }
     
int gcd(int v,int b){
	if(v>b) return gcd(b,v);
	if(v==b) return b;
	if(b%v==0) return v;
	return gcd(v,b%v);
}
            double dot(Vector a,Vector b){
            	return a.x*b.x+a.y*b.y;
            }
            double cross(Vector a,Vector b){
            	return a.x*b.y-a.y*b.x;
            }
        
            //----------------kokomade tenpure------------

int dp[400][400][400]={0};
    signed main(){
	
	dp[0][1][1]=1;
    	
    	int n,m;
    	cin>>n>>m;
    	
    	for(int i=0;i<=m;i++)for(int j=1;j<=i+1;j++)for(int k=1;k<=j;k++){
    	//	cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<endl; 
    		int u=dp[i][j][k];
    		
    		dp[i+1][j][j] += k*u;
    		dp[i+1][j][j] %= inf;
    		dp[i+1][j][k] += (j-k)*u;
    		dp[i+1][j][k] %= inf;
    		dp[i+1][j+1][k] += (n-j)*u;
    		dp[i+1][j+1][k] %=inf;
    	}
    
    
    	
    	cout<<dp[m][n][n]<<endl;
    	
    //	printf("%.10f\n",ans);
    	return 0;
    }

Submission Info

Submission Time
Task F - Road of the King
User smiken
Language C++14 (GCC 5.4.1)
Score 1000
Code Size 3050 Byte
Status AC
Exec Time 304 ms
Memory 144128 KB

Judge Result

Set Name sample all
Score / Max Score 0 / 0 1000 / 1000
Status
AC × 3
AC × 13
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 3 ms 256 KB
01-02.txt AC 3 ms 256 KB
01-03.txt AC 300 ms 144128 KB
01-04.txt AC 3 ms 256 KB
01-05.txt AC 300 ms 144128 KB
01-06.txt AC 299 ms 144128 KB
01-07.txt AC 300 ms 143104 KB
01-08.txt AC 300 ms 144128 KB
01-09.txt AC 301 ms 144128 KB
01-10.txt AC 303 ms 144128 KB
sample-01.txt AC 3 ms 256 KB
sample-02.txt AC 304 ms 144128 KB
sample-03.txt AC 77 ms 36864 KB