이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
#ifndef ONLINE_JUDGE
#include "AkbarKING.h" // aska geldi akbarking.h
#else
#define debug(...)
#define debugArr(...)
#define debugG(...)
#endif
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#define int long long
#define $AzH_TxdmN$ ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#define ep emplace_back
#define pb push_back
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using __indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using __indexed_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int sz = 3e5+9;
const int LOG = 63;
const int MOD = 1e9+7;
const int INF = 1e18;
int n,cs,cf;
int res;
void dfs(int node,int fuel,int state,vector<bool>dp)
{
//cerr << node << ' ' << fuel << ' ' << state << endl;
if (node < 1 || node > n || dp[node]) return;
if(fuel == 0 && node == cf)
{
res = (res + 1) % MOD;
return;
}
dp[node] = 1;
if (state == 2)
{
for (int i = 0; i <= 10; ++i)
{
dfs(node+i,fuel-1,0,dp);
dfs(node-i,fuel-1,1,dp);
}
}
else if (state == 0)
{
for (int i = 1; i <= 10; ++i)
{
dfs(node-i,fuel-1,1,dp);
}
}
else
{
for (int i = 1; i <= 10; ++i)
{
dfs(node+i,fuel-1,0,dp);
}
}
}
void solve()
{
cin>>n>>cs>>cf;
vector<bool>dp(20);
dfs(cs,n-1,2,dp);
cout<<res<<'\n';
}
signed main()
{
$AzH_TxdmN$
//freopen("kangaroo.in", "r", stdin);
//freopen("kangaroo.out", "w", stdout);
int t = 1;
//cin>>t;
while (t--)
{
solve();
}
}
# | 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... |