#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <queue>
using namespace std;
long long con[105][105]={0};
vector < pair < long long , long long > > all;
vector < char > ans[105];
priority_queue < pair < long long , pair < long long , long long > > ,vector < pair < long long , pair < long long , long long > > >, less < pair < long long , pair < long long , long long > > > > how;
int main()
{
long long i,j,N=0,M=0,now=0,n,last;
scanf("%lld",&n);
con[1][1]=1;
if(n<=19)
{
for(i=1;i<=4;i++)
{
for(j=1;j<=4;j++)
{
if(i>1&&con[i-1][j]>=0) con[i][j]+=con[i-1][j];
else if(i>1) con[i][j]=-1e18;
if(j>1&&con[i][j-1]>=0) con[i][j]+=con[i][j-1];
else if(j>1) con[i][j]=-1e18;
if(con[i][j]>n) con[i][j]=-1e18;
else how.push(make_pair(con[i][j],make_pair(i,j)));
}
}
}
else
{
for(i=1;i<=100;i++)
{
for(j=1;j<=100;j++)
{
if(i>1&&con[i-1][j]>=0) con[i][j]+=con[i-1][j];
else if(i>1) con[i][j]=-1e18;
if(j>1&&con[i][j-1]>=0) con[i][j]+=con[i][j-1];
else if(j>1) con[i][j]=-1e18;
if(con[i][j]>n) con[i][j]=-1e18;
else how.push(make_pair(con[i][j],make_pair(i,j)));
}
}
}
while(n)
{
//printf("%lld\n",n);
while(n<how.top().first) how.pop();
all.push_back(how.top().second);
n-=how.top().first;
N=max(N,how.top().second.first);
M+=how.top().second.second;
}
//printf("%lld %lld\n",N,M);
for(i=0;i<=N;i++)
{
for(j=0;j<M;j++) ans[i].push_back('X');
}
for(j=0;j<M;j++) ans[0][j]='r';
for(auto i:all)
{
//printf("%lld %lld\n",i.first,i.second);
ans[0][now]='X';
last=now;
for(j=1;j<=N;j++) ans[j][now+i.second-1]='d';
for(j=1;j<=N-i.first;j++) ans[j][now]='d';
now+=i.second;
}
ans[0][last]='d';
for(i=0;i<N;i++) ans[i][M-1]='d';
for(i=0;i<M;i++) ans[N][i]='r';
ans[N][M-1]='.';
printf("%lld %lld\n",N+1,M);
for(i=0;i<=N;i++)
{
for(j=0;j<M;j++) printf("%c",ans[i][j]);
printf("\n");
}
return 0;
}
Compilation message
costinland.cpp: In function 'int main()':
costinland.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
16 | scanf("%lld",&n);
| ~~~~~^~~~~~~~~~~
costinland.cpp:15:35: warning: 'last' may be used uninitialized in this function [-Wmaybe-uninitialized]
15 | long long i,j,N=0,M=0,now=0,n,last;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct! Your size: 4 |
2 |
Correct |
1 ms |
204 KB |
Correct! Your size: 5 |
3 |
Correct |
1 ms |
204 KB |
Correct! Your size: 5 |
4 |
Correct |
1 ms |
204 KB |
Correct! Your size: 4 |
5 |
Correct |
1 ms |
204 KB |
Correct! Your size: 5 |
6 |
Correct |
1 ms |
204 KB |
Correct! Your size: 5 |
7 |
Correct |
1 ms |
204 KB |
Correct! Your size: 5 |
8 |
Correct |
1 ms |
204 KB |
Correct! Your size: 5 |
9 |
Partially correct |
1 ms |
204 KB |
Partially Correct! Your size: 8 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
3 ms |
780 KB |
Partially Correct! Your size: 107 |
2 |
Partially correct |
3 ms |
780 KB |
Partially Correct! Your size: 96 |
3 |
Partially correct |
3 ms |
780 KB |
Partially Correct! Your size: 117 |
4 |
Partially correct |
3 ms |
780 KB |
Partially Correct! Your size: 97 |
5 |
Partially correct |
3 ms |
780 KB |
Partially Correct! Your size: 115 |
6 |
Partially correct |
3 ms |
780 KB |
Partially Correct! Your size: 92 |
7 |
Partially correct |
3 ms |
780 KB |
Partially Correct! Your size: 92 |
8 |
Partially correct |
3 ms |
780 KB |
Partially Correct! Your size: 98 |