이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define fi first
#define se second
#define ll long long
#define pb push_back
#define ii pair<int,int>
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int nax=5e4+5;
const int MOD=1e9+7;
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
long long dp[205][205][205][2];
int n,s,t;
long long dfs(int x,int y,int z,int t){
if(x==1&&y==0&&z==0) return 1;
if(x==0) return 0;
if(dp[x][y][z][t]!=-1) return dp[x][y][z][t];
dp[x][y][z][t]=0;
for (int i = 0; i < x; ++i)
{
if(i==y||(i==z&&x>2)) continue;
if((i>y) != t) continue;
dp[x][y][z][t]+= dfs(x-1,((i>y) ? i-1 : i),((y<z) ? z-1 : z), !t);
dp[x][y][z][t]%=MOD;
}
//cout <<x<<" "<<y<<" "<<z<<" "<<t<<" "<<dp[x][y][z][t]<<endl;
return dp[x][y][z][t];
}
int main()
{
optimise;
cin>>n>>s>>t;
s--;t--;
if(s>t) swap(s,t);
memset(dp,-1,sizeof dp);
cout << (dfs(n,s,t,0)+dfs(n,s,t,1))%MOD <<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |