답안 #500485

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
500485 2021-12-31T07:27:36 Z asakh Red-blue table (IZhO19_stones) C++17
27 / 100
28 ms 1388 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ull unsigned ll
#define ld long double
#define pb push_back
#define ppb pop_back
#define clr clear
#define len size()
#define beg begin()
#define end end()
#define ins insert
#define f first
#define s second
#define y1 y123456789
#define forn(i, l, r) for(int i = l; i <= r; ++i)
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

using namespace std;
using namespace __gnu_pbds;

typedef tree < int, null_type, greater_equal < int >, 
				rb_tree_tag, tree_order_statistics_node_update > ordered_set;

int t, n, m;

const int MAXN = 1020;

char a[MAXN][MAXN];

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	fastio;

	cin >> t;
	
	while (t--)
	{
		cin >> n >> m;
		
		if (n & 1)
		{
			if (m & 1)
			{
				if (n + m / 2 > m + n / 2)
				{
					for (int j = 1; j <= m / 2 + 1; ++j)
						for (int i = 1; i <= n; ++i)
							a[i][j] = '+';
					for (int j = m / 2 + 2; j <= m; ++j)
						for (int i = 1; i <= n; ++i)
							a[i][j] = '-';
				}
				else
				{
					for (int j = 1; j <= m; ++j)
						for (int i = 1; i <= n / 2 + 1; ++i)
							a[i][j] = '-';
					for (int j = 1; j <= m; ++j)
						for (int i = n / 2 + 2; i <= n; ++i)
							a[i][j] = '+';
				}
				
				cout << max(n + m / 2, m + n / 2);
			}
			else
			{
				if (m + n / 2 > n + (m - 1) / 2)
				{
					for (int j = 1; j <= m; ++j)
						for (int i = 1; i <= n / 2 + 1; ++i)
							a[i][j] = '-';
					for (int j = 1; j <= m; ++j)
						for (int i = n / 2 + 2; i <= n; ++i)
							a[i][j] = '+';
				}
				else
				{
					for (int j = 1; j <= m / 2 + 1; ++j)
						for (int i = 1; i <= n; ++i)
							a[i][j] = '+';
					for (int j = m / 2 + 2; j <= m; ++j)
						for (int i = 1; i <= n; ++i)
							a[i][j] = '-';
				}
				
				cout << max(m + n / 2, n + (m - 1) / 2);
			}
		}
		else
		{
			if (m & 1)
			{
				if (n + m / 2 < m + (n - 1) / 2)
				{
					for (int j = 1; j <= m; ++j)
						for (int i = 1; i <= n / 2 + 1; ++i)
							a[i][j] = '-';
					for (int j = 1; j <= m; ++j)
						for (int i = n / 2 + 2; i <= n; ++i)
							a[i][j] = '+';
				}
				else
				{
					for (int j = 1; j <= m / 2 + 1; ++j)
						for (int i = 1; i <= n; ++i)
							a[i][j] = '+';
					for (int j = m / 2 + 2; j <= m; ++j)
						for (int i = 1; i <= n; ++i)
							a[i][j] = '-';
				}
				
				cout << max(n + m / 2, m + (n - 1) / 2);
			}
			else
			{
				if (n + (m - 1) / 2 < m + (n - 1) / 2)
				{
					for (int j = 1; j <= m; ++j)
						for (int i = 1; i <= n / 2 + 1; ++i)
							a[i][j] = '-';
					for (int j = 1; j <= m; ++j)
						for (int i = n / 2 + 2; i <= n; ++i)
							a[i][j] = '+';
				}
				else
				{
					for (int j = 1; j <= m / 2 + 1; ++j)
						for (int i = 1; i <= n; ++i)
							a[i][j] = '+';
					for (int j = m / 2 + 2; j <= m; ++j)
						for (int i = 1; i <= n; ++i)
							a[i][j] = '-';
				}
				
				cout << max(n + (m - 1) / 2, m + (n - 1) / 2);
			}
		}
		cout << '\n';
		
		for (int i = 1; i <= n; ++i)
		{
			for (int j = 1; j <= m; ++j)
				cout << a[i][j];
			cout << '\n';
		}
	}

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Incorrect 2 ms 332 KB Wrong answer in test 5 29: 31 < 32
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 1388 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 1356 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Incorrect 2 ms 332 KB Wrong answer in test 5 29: 31 < 32