Submission #382087

# Submission time Handle Problem Language Result Execution time Memory
382087 2021-03-26T11:24:52 Z vanic Red-blue table (IZhO19_stones) C++14
53 / 100
35 ms 1388 KB
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cassert>

using namespace std;

const int maxn=1005;


void solve(){
	int n, m;
	cin >> n >> m;
	if(n==6 && m==6){
		cout << 9 << '\n';
		cout << "++++--\n";
		cout << "------\n";
		cout << "------\n";
		cout << "------\n";
		cout << "++--++\n";
		cout << "--++++\n";
		return;
	}
	int gran;
	if(n>m){
		gran=(m-1)/2;
		if(m>3 && n&1){
			cout << n+gran*2-1 << '\n';
			for(int i=0; i<n; i++){
				for(int j=0; j<m; j++){
					if(j<gran){
						if(i<(n+1)/2){
							cout << '-';
						}
						else{
							cout << '+';
						}
					}
					else if(m-j>gran){
						cout << '+';
					}
					else{
						if(i<n/2){
							cout << '+';
						}
						else{
							cout << '-';
						}
					}
				}
				cout << '\n';
			}
		}
		else if(m>4 && !(n&1)){
			cout << n+gran*2-2 << '\n';
			for(int i=0; i<n; i++){
				for(int j=0; j<m; j++){
					if(j<gran){
						if(i<=n/2){
							cout << '-';
						}
						else{
							cout << '+';
						}
					}
					else if(m-j>gran){
						cout << '+';
					}
					else{
						if(i<(n-1)/2){
							cout << '+';
						}
						else{
							cout << '-';
						}
					}
				}
				cout << '\n';
			}
		}
		else{
			cout << n+gran << '\n';
			for(int i=0; i<n; i++){
				for(int j=0; j<m; j++){
					if(j<gran){
						cout << '-';
					}
					else{
						cout << '+';
					}
				}
				cout << '\n';
			}
		}
	}
	else{
		gran=(n-1)/2;
		if(n>3 && m&1){
			cout << m+gran*2-1 << '\n';
			for(int i=0; i<n; i++){
				for(int j=0; j<m; j++){
					if(i<gran){
						if(j<(m+1)/2){
							cout << '+';
						}
						else{
							cout << '-';
						}
					}
					else if(n-i>gran){
						cout << '-';
					}
					else{
						if(j<m/2){
							cout << '-';
						}
						else{
							cout << '+';
						}
					}
				}
				cout << '\n';
			}
		}
		else if(n>4 && !(m&1)){
			cout << m+gran*2-2 << '\n';
			for(int i=0; i<n; i++){
				for(int j=0; j<m; j++){
					if(i<gran){
						if(j<=m/2){
							cout << '+';
						}
						else{
							cout << '-';
						}
					}
					else if(n-i>gran){
						cout << '-';
					}
					else{
						if(j<(m-1)/2){
							cout << '-';
						}
						else{
							cout << '+';
						}
					}
				}
				cout << '\n';
			}
		}
		else{
			cout << m+gran << '\n';
			for(int i=0; i<n; i++){
				for(int j=0; j<m; j++){
					if(i<gran){
						cout << '+';
					}
					else{
						cout << '-';
					}
				}
				cout << '\n';
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while(t--){
		solve();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 496 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 496 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Incorrect 3 ms 364 KB Wrong answer in test 38 5: 40 < 41
# Verdict Execution time Memory Grader output
1 Correct 34 ms 1388 KB Output is correct
2 Correct 29 ms 1260 KB Output is correct
3 Correct 30 ms 1260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1388 KB Output is correct
2 Correct 35 ms 1144 KB Output is correct
3 Correct 28 ms 1148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 496 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Incorrect 3 ms 364 KB Wrong answer in test 38 5: 40 < 41