Submission #500601

# Submission time Handle Problem Language Result Execution time Memory
500601 2021-12-31T14:18:45 Z asakh Red-blue table (IZhO19_stones) C++17
0 / 100
2000 ms 952 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;

int cnt[MAXN];
char a[MAXN][MAXN];

int add(int y)
{
	if (y == n)
		return 1;
	return y + 1;
}

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

	fastio;

	cin >> t;
	
	while (t--)
	{
		memset(cnt, 0, sizeof(cnt));
		
		cin >> n >> m;
		
		bool tr = n < m;
		
		if (tr)
			swap(n, m);
		
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= m; ++j)
				a[i][j] = '+';
		
		int y = 1, x = 1, ans = n, c = 0;
		while (true)
		{
			a[y][x] = '-';
			++cnt[x];
			++c;
			if (cnt[x] == n / 2 + 1)
				++x, ++ans;
			y = add(y);
			if (c == n * ((m - 1) / 2))
				break;
		}
		
		cout << ans << '\n';
		if (tr)
		{
			for (int i = 1; i <= m; ++i)
			{
				for (int j = 1; j <= n; ++j)
					cout << (a[i][j] == '+' ? '-' : '+');
				cout << '\n';
			}
		}
		else
		{
			for (int i = 1; i <= n; ++i)
			{
				for (int j = 1; j <= m; ++j)
					cout << a[i][j];
				cout << '\n';
			}
		}
	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 2041 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2037 ms 312 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2041 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2073 ms 444 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2069 ms 952 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2041 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -