Submission #498719

# Submission time Handle Problem Language Result Execution time Memory
498719 2021-12-26T09:03:00 Z NachoLibre Red-blue table (IZhO19_stones) C++17
38 / 100
34 ms 1868 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;

void print(vector<vector<char> > &c, bool sw) {
	if(sw) {
		for(int j = 0; j < sz(c[0]); ++j) {
			for(int i = sz(c) - 1; i >= 0; --i) {
				cout << char('+' ^ '-' ^ c[i][j]);
			}
			cout << "\n";
		}
		return;
	}
	for(int i = 0; i < sz(c); ++i) {
		for(int j = 0; j < sz(c[0]); ++j) {
			cout << c[i][j];
		}
		cout << "\n";
	}
}


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	for(int ti = 1; ti <= t; ++ti) {
		int n, m;
		cin >> n >> m;
		bool sw = 0;
		if(n > m) { swap(n, m); sw = 1; }
		int x[2] = {n / 2 + 1, (n + 1) / 2 - 1};
		int y[2] = {m / 2 + 1, (m + 1) / 2 - 1};
		vector<vector<char> > c(n, vector<char>(m, '+'));
		for(int i = 0; i < x[0]; ++i) {
			for(int j = 0; j < y[1]; ++j) {
				c[i][j] = '-';
			}
		}
		for(int i = 0; i < x[1]; ++i) {
			for(int j = y[1]; j < m; ++j) {
				c[i][j] = '+';
			}
		}
		for(int i = x[0]; i < n; ++i) {
			for(int j = 0; j < y[0]; ++j) {
				c[i][j] = '+';
			}
		}
		for(int i = x[1]; i < n; ++i) {
			for(int j = y[0]; j < m; ++j) {
				c[i][j] = '-';
			}
		}
		int fp1 = x[1] + y[1] << 1;
		if(m + x[1] > fp1) {
			cout << m + x[1] << "\n";
			c = vector<vector<char>>(n, vector<char>(m, '-'));
			for(int i = 0; i < x[1]; ++i) {
				for(int j = 0; j < m; ++j) {
					c[i][j] = '+';
				}
			}
			print(c, sw);
			continue;
		}
		cout << fp1 << "\n";
		print(c, sw);
	}
	return 0;
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:60:18: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   60 |   int fp1 = x[1] + y[1] << 1;
      |             ~~~~~^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 2 ms 308 KB Wrong answer in test 38 5: 40 < 41
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1244 KB Output is correct
2 Correct 24 ms 1612 KB Output is correct
3 Correct 21 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 1300 KB Wrong answer in test 6 6: 8 < 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 2 ms 308 KB Wrong answer in test 38 5: 40 < 41