Submission #209928

# Submission time Handle Problem Language Result Execution time Memory
209928 2020-03-16T02:12:13 Z super_j6 Red-blue table (IZhO19_stones) C++14
100 / 100
120 ms 5328 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
#include <queue>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
#define f first
#define s second

const int maxn = 1000;
int n, m;
int a[maxn][maxn];
queue<pi> q;

void answer(){
	cin >> n >> m;
	
	bool f = 0;
	if(n < m){
		swap(n, m);
		f = 1;
	}
	
	for(int i = 0; i < n; i++){
		if((m - 1) / 2) q.push({i, (m - 1) / 2});
	}
	
	int ret = 0;
	memset(a, 0, sizeof(a));
	for(int i = n / 2; !q.empty();i--){
		pi p = q.front();
		q.pop();
		
		a[p.f][ret] = 1;
		if(--p.s) q.push(p);
		
		if(!i){
			ret++;
			i = n / 2 + 1;
		}
	}
	ret += n;
	
	if(f) swap(n, m);
	cout << ret << endl;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cout << ((f ? a[j][i] : a[i][j]) ^ f ? '-' : '+');
		}
		cout << endl;
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int t;
	cin >> t;
	
	for(int i = 0; i < t; i++) answer();

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4216 KB Output is correct
2 Correct 9 ms 4220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 4216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4216 KB Output is correct
2 Correct 9 ms 4220 KB Output is correct
3 Correct 45 ms 4216 KB Output is correct
4 Correct 69 ms 4348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 94 ms 5328 KB Output is correct
2 Correct 32 ms 5112 KB Output is correct
3 Correct 32 ms 5120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 5240 KB Output is correct
2 Correct 31 ms 5112 KB Output is correct
3 Correct 29 ms 4984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4216 KB Output is correct
2 Correct 9 ms 4220 KB Output is correct
3 Correct 45 ms 4216 KB Output is correct
4 Correct 69 ms 4348 KB Output is correct
5 Correct 94 ms 5328 KB Output is correct
6 Correct 32 ms 5112 KB Output is correct
7 Correct 32 ms 5120 KB Output is correct
8 Correct 57 ms 5240 KB Output is correct
9 Correct 31 ms 5112 KB Output is correct
10 Correct 29 ms 4984 KB Output is correct
11 Correct 120 ms 4472 KB Output is correct
12 Correct 29 ms 5112 KB Output is correct
13 Correct 32 ms 5112 KB Output is correct
14 Correct 25 ms 4856 KB Output is correct
15 Correct 37 ms 5240 KB Output is correct
16 Correct 30 ms 4984 KB Output is correct
17 Correct 17 ms 4728 KB Output is correct