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>
#define ll long long
#define ld long double
#define fi first
#define se second
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int c[10][10];int k;
char a[10][19],b[10][10];
int get()
{
for(int i=1;i<5;i++)for(int j=1;j<5;j++)c[i][j]=0;
c[1][1]=1;
for(int i=1;i<=4;i++)
{
for(int j=1;j<=4;j++)
{
int x=c[i][j];
/*
*/
if(a[i][j]=='X')
{
c[i][j+1]+=x;
c[i+1][j]+=x;continue;
}
if(a[i][j]=='r')
{
c[i][j+1]+=x;continue;
}
if(a[i][j]=='d')c[i+1][j]+=x;
}
}
return c[4][4];
}
void go(int x,int y)
{
if(x==4&&y==4)
{
ll u=get();
if(u==k)
{
for(int i=1;i<=4;i++)
{
for(int j=1;j<=4;j++)b[i][j]=a[i][j];
}
return;
}
return;
}
if(y==4)
{
go(x+1,1);return;
}
a[x][y]='X';
go(x,y+1);
a[x][y]='d';
go(x,y+1);
a[x][y]='r';
go(x,y+1);
return;
}
int main()
{
cin>>k;b[1][1]='w';
a[1][4]='d';
a[2][4]='d';
a[3][4]='d';
a[4][4]='.';
a[4][1]='r';
a[4][2]='r';
a[4][3]='r';
go(1,1);cout<<4<<" "<<4<<endl;
for(int i=1;i<5;i++)
{
for(int j=1;j<5;j++)cout<<b[i][j];
cout<<endl;
}
}/*
rrXd
rrrd
rrrd
rrrd
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |