제출 #981840

#제출 시각아이디문제언어결과실행 시간메모리
981840Requiem캥거루 (CEOI16_kangaroo)C++17
100 / 100
29 ms32204 KiB
#include<bits/stdc++.h> #define int long long #define pb push_back #define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); #define MOD 1000000007 #define INF 1e18 #define fi first #define se second #define FOR(i,a,b) for(int i=a;i<=b;i++) #define FORD(i,a,b) for(int i=a;i>=b;i--) #define sz(a) ((int)(a).size()) #define endl '\n' #define pi 3.14159265359 #define TASKNAME "kangaroo" template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; } template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; } using namespace std; typedef pair<int,int> ii; typedef pair<int,ii> iii; typedef vector<int> vi; const int MAXN = 2009; int dp[MAXN][MAXN],in=0,n,s,t; int solve(int pos,int component,int in){ // cout<<pos<<' '<<component<<endl; if (pos==n+1){ if (component==1) return 1; else return 0; } int &res = dp[pos][component]; if (res != -1) return res; res = 0; if (pos==s){ if (component>0 && (in==0 || (in>0 && (component>1 || pos==n)))) res =(res + solve(pos+1,component,in+1))%MOD; res = (res + solve(pos+1,component+1,in+1))%MOD; } else if (pos == t) { if (component>0 && (in==0 || (in>0 && (component>1 || pos==n)))) res =(res + solve(pos+1,component,in+1))%MOD; res =(res + solve(pos+1,component+1,in+1))%MOD; } else{ int mulfactor = component+1 - in; res = (res + solve(pos+1,component+1,in) * mulfactor)%MOD; // tao 1 tplt moi if (component>1){ //noi 2 tplt res = (res + solve(pos+1,component-1,in) * (component-1))%MOD; } } return res; } main() { fast; // freopen(TASKNAME".inp","r",stdin); // freopen(TASKNAME".out","w",stdout); cin>>n>>s>>t; memset(dp,-1,sizeof(dp)); int ans = solve(1,0,0); cout<<ans<<endl; }

컴파일 시 표준 에러 (stderr) 메시지

kangaroo.cpp:51:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   51 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...