Submission #525288

# Submission time Handle Problem Language Result Execution time Memory
525288 2022-02-11T09:11:51 Z Magi Red-blue table (IZhO19_stones) C++14
0 / 100
41 ms 2412 KB
#include <iostream>
#define NMAX 1000

using namespace std;

char a[NMAX+10][NMAX+10];

void solve(){

	int n, m;
	cin >> n >> m;

	int badColumns = 0;
	int ans = max(n, m), p = 0;
	if(n > m)
		p = n;

	for(int i=1; i<=n; i++){
		int cnt = (m / 2 + 1) * i;
		if(cnt > (m - badColumns) * (n / 2) + badColumns * i){
			if(badColumns == m)
				break;
			i--;
			badColumns++;
			continue;
		}
		if(i + (m - badColumns) > ans){
			ans = i + (m - badColumns);
			p = i;
		}
	}

	badColumns = 0;
	while(1){
		int cnt = (m / 2 + 1) * p;
		if(cnt > (m - badColumns) * (n / 2) + badColumns * p){
			badColumns++;
			continue;
		}
		for(int j=1; j<=m; j++)
			for(int i=1; i<=n; i++){
				if(j <= badColumns)
					a[i][j] = '+';
				else
					a[i][j] = '-';
			}

		int j = badColumns + 1;	
		for(int i=1; i<=p; i++)
			for(int nr=1; nr<=m/2+1-badColumns; nr++){
				a[i][j] = '+';
				j++;
				if(j == m + 1)
					j = badColumns + 1;
			}
		for(int i=1; i<=n; i++){
			for(int j=1; j<=m; j++)
				cout << a[i][j] << ' ';
			cout << '\n';
		}
		break;
	}
}

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t;
	cin >> t;
	while(t--){
		solve();
	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Expected integer, but "-" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Expected integer, but "+" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Expected integer, but "-" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 2372 KB Expected integer, but "+" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 2412 KB Expected integer, but "+" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Expected integer, but "-" found
2 Halted 0 ms 0 KB -