# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
1090258 | | ASN49K | W (RMI18_w) | C++14 | | 159 ms | 600 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int add(int x,int y)
{
return (x+y)%mod;
}
int prod(int x,int y)
{
return (1LL*x*y)%mod;
}
void add_self(int& x,int y)
{
x+=y;
x%=mod;
}
const int MASK=(1<<5);
int bit_k(int x,int k)
{
return (x>>k)&1;
}
vector<int>masks={31,30,27,26,24,15,14,11,10,8,3,2};
int main()
{
int n;
cin>>n;
vector<int>dp(MASK,0);
dp[0]=1;
for(int step=0;step<n;step++)
{
for(int mask=MASK-1;mask>0;mask--)
{
vector<int>bit(5);
for(int j=0;j<5;j++)
{
bit[j]=(bit_k(mask,j));
}
int rez=0;
if(!((bit[0] && !bit[1]) ||
(bit[2] && !bit[1]) ||
(bit[2] && !bit[3]) ||
(bit[4] && !bit[3]))
)
{
for(int j=0;j<5;j++)
{
if(bit[j])
{
add_self(rez , dp[mask^(1<<j)]);
}
}
int nr=0;
nr+=bit[0];
nr+=bit[4];
nr+=(bit[2]==0 && bit[1]==1);
nr+=(bit[2]==0 && bit[3]==1);
add_self(rez , prod(dp[mask] , nr));
}
dp[mask]=rez;
}
dp[0]=0;
}
cout<<dp[MASK-1];
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |