답안 #523862

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
523862 2022-02-08T10:06:13 Z Baytoro Costinland (info1cup19_costinland) C++17
100 / 100
1 ms 324 KB
#include <bits/stdc++.h>
using namespace std;
#define Baytoro_MayrambekovOrz void solve()
#define ios ios::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define int long long
#define endl '\n'
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
void fopn(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
int binpow(int a,int n){
	if(n==0)
		return 1;
	if(n%2==1)
		return binpow(a, n-1)*a;
	else{
		int b=binpow(a, n/2);
		return b*b;
	}
}
char ar[55][55];
int dp[55][55];
int a,b,c,n,m,i,j,k,x,y,cnt=0,sum=0,res=0;
Baytoro_MayrambekovOrz{
	ar[1][1]='X';
	dp[1][1]=1;
	for(i=1;i<=48;i++){
		for(j=1;j<=48;j++){
			if(j>=i){
				if(j-i<=2){
					ar[i][j]='X';
					dp[i+1][j]+=dp[i][j];
					dp[i][j+1]+=dp[i][j];
				}
				else{
					ar[i][j]='.';
					dp[i][j+1]+=dp[i][j];
				}
			}
			else{
				if(i-j==1){
					ar[i][j]='X';
					dp[i+1][j]+=dp[i][j];
					dp[i][j+1]+=dp[i][j];
				}
				else{
					ar[i][j]='.';
					dp[i+1][j]+=dp[i][j];
				}
			}
		}
	}
	cin>>n;
	int k=46;
	while(dp[k][k]>n)
		k--;
	cout<<k+1<<' '<<k+1<<endl;
	n-=dp[k][k];
	ar[k][k]='.';
	for(i=k-1;i>=1;i--){
		
		if(dp[i][k]>n)
			ar[i][min(i+2,k)]='d';
		else
			n-=dp[i][k];
		if(dp[k][i]>n)
			ar[i+1][i]='r';
		else
			n-=dp[k][i];
		
	}
	for(i=1;i<=k;i++){
		for(j=1;j<=k;j++){
			cout<<ar[i][j];
		}
		cout<<"d\n";
	}
	for(i=1;i<=k;i++)
		cout<<"r";
	cout<<'.';
	//cout<<dp[k][k];
}
main(){
//	ios;
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}


Compilation message

costinland.cpp:90:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   90 | main(){
      | ^~~~
costinland.cpp: In function 'void fopn(std::string)':
costinland.cpp:15:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
costinland.cpp:16:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Correct! Your size: 3
2 Correct 1 ms 204 KB Correct! Your size: 3
3 Correct 0 ms 204 KB Correct! Your size: 4
4 Correct 0 ms 204 KB Correct! Your size: 4
5 Correct 1 ms 204 KB Correct! Your size: 4
6 Correct 0 ms 204 KB Correct! Your size: 4
7 Correct 0 ms 204 KB Correct! Your size: 4
8 Correct 0 ms 204 KB Correct! Your size: 5
9 Correct 1 ms 324 KB Correct! Your size: 5
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Correct! Your size: 44
2 Correct 1 ms 320 KB Correct! Your size: 44
3 Correct 1 ms 324 KB Correct! Your size: 45
4 Correct 1 ms 204 KB Correct! Your size: 44
5 Correct 1 ms 204 KB Correct! Your size: 45
6 Correct 0 ms 204 KB Correct! Your size: 45
7 Correct 1 ms 204 KB Correct! Your size: 45
8 Correct 1 ms 320 KB Correct! Your size: 43