Submission #498713

# Submission time Handle Problem Language Result Execution time Memory
498713 2021-12-26T08:44:30 Z NachoLibre Red-blue table (IZhO19_stones) C++17
11 / 100
37 ms 1856 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) {
	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;
		if(n < 3 && n < m) {
			vector<vector<char> > c(n, vector<char>(m, '-'));
			cout << m << "\n";
			print(c);
			continue;
		} else if(m < 3) {
			vector<vector<char> > c(n, vector<char>(m, '+'));
			cout << n << "\n";
			print(c);
			continue;
		}
		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] = '-';
			}
		}
		cout << (x[1] + y[1] << 1) << "\n";
		print(c);
	}
	return 0;
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:60:17: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   60 |   cout << (x[1] + y[1] << 1) << "\n";
      |            ~~~~~^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Incorrect 1 ms 312 KB Wrong answer in test 4 4: 4 < 5
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Wrong answer in test 4 3: 4 < 5
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Incorrect 1 ms 312 KB Wrong answer in test 4 4: 4 < 5
# Verdict Execution time Memory Grader output
1 Correct 34 ms 1300 KB Output is correct
2 Correct 24 ms 1596 KB Output is correct
3 Correct 22 ms 1856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 1352 KB Wrong answer in test 4 4: 4 < 5
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Incorrect 1 ms 312 KB Wrong answer in test 4 4: 4 < 5