답안 #315138

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
315138 2020-10-22T03:17:39 Z yjojdkgk5bp Costinland (info1cup19_costinland) C++14
11.9757 / 100
500 ms 23852 KB
#include <bits/stdc++.h>
#define ll long long
#define sec second
#define ft first
#define pb push_back
using namespace std;
ll k,dp[50][50],sum1[50][50],sum2[50][50],mx,a,b;
vector<pair<int,int>> p;
int ans[50][50];
int main()
{
	cin >> k;
	dp[0][1]=1;
	for(int i=1; i<33; i++)
		for(int j=1; j<33; j++)
		{
			dp[i][j]=dp[i-1][j]+dp[i][j-1];
			sum1[i][j]=sum1[i-1][j]+dp[i][j];
			sum2[i][j]=sum2[i][j-1]+dp[i][j];
			ll v=sum1[i][j]+sum2[i][j];
			if(sum1[i][j]+sum2[i][j]<=k && i>=j &&max(i,j)<=5 && (mx<v || (mx==v&&max(i,j)<max(a,b))))
				mx=v,a=i,b=j;
		}/*
	for(int i=32; i&&k; i--)
		for(int j=i; j&&k; j--)
		{
			if(sum1[i][j]+sum2[i][j]<=k)
			{//
				k-=sum1[i][j]+sum2[i][j];
				p.pb({i,j});
			}
		}*/
	k-=mx;
	if(k)
	{
		cout << a+1 << ' ' << b+1+k << '\n';
		for(int i=0; i<=a; cout<<'\n',i++)
			for(int j=0; j<=b+k; j++)
			{
				if(i&&i<a&&j<k) cout << 'd';
				else if(i<a&&j==b+k) cout << 'd';
				else if(i==a&&j<b+k) cout << 'r';
				else if(i==a&&j==b+k) cout << '.';
				else cout << 'X';
			}
	}
	else
	{
		cout << a+1 << ' ' << b+1 << '\n';
		for(int i=0; i<=a; cout<<'\n',i++)
			for(int j=0; j<=b; j++)
			{
				if(i==a&&j==b) cout << '.';
				else if(i==a) cout << 'r';
				else if(j==b) cout << 'd';
				else cout << 'X';
			}
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Correct! Your size: 3
2 Correct 1 ms 332 KB Correct! Your size: 4
3 Correct 1 ms 332 KB Correct! Your size: 5
4 Correct 1 ms 332 KB Correct! Your size: 3
5 Correct 1 ms 332 KB Correct! Your size: 4
6 Correct 1 ms 332 KB Correct! Your size: 5
7 Correct 1 ms 332 KB Correct! Your size: 4
8 Partially correct 1 ms 332 KB Partially Correct! Your size: 7
9 Partially correct 1 ms 332 KB Partially Correct! Your size: 7
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1052 ms 23852 KB Time limit exceeded
2 Halted 0 ms 0 KB -