Submission #334507

# Submission time Handle Problem Language Result Execution time Memory
334507 2020-12-09T09:36:38 Z Gurban Red-blue table (IZhO19_stones) C++17
38 / 100
38 ms 3052 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int maxn=1e3+5;
int tt;
int n,m,jog,st,now;
char c[maxn][maxn],p[maxn][maxn];

void f(int n,int m){
	int num = (m - 1)/2,num1 = m-num;
	int nw = (n - 1) / 2,nw1 = n - nw;
	jog = n + num;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= num1;j++) c[i][j] = '+';
		for(int j = num1+1;j <= m;j++) c[i][j] = '-';
	}

	int ay = 0; if(n % 2 == 0) ay++;
	if(m % 2 == 0) ay++;

	// cout<<num<<' '<<num1<<' '<<nw<<' '<<nw1<<'\n';

	if(n+m-2-ay > n + num){
		jog = n+m-2-ay;
		for(int i = 1;i <= n;i++) for(int j = 1;j <= m;j++) c[i][j]='+';
		for(int i = m;i > num1;i--) for(int j = 1;j <= nw1;j++) c[j][i]='-';
		st = 1; if(m % 2 == 0) st=2;
		for(int i = num1;i > st;i--) for(int j = n;j > nw1;j--) c[j][i]='-';
		for(int i = 1;i <= m;i++) c[nw1][i]='-';
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> tt;
	while(tt--){
		cin >> n >> m;
		f(n,m);
		now = jog;
		for(int i = 1;i <= n;i++){
			for(int j = 1;j <= m;j++){
				p[i][j] = c[i][j];
			}
		}
		f(m,n);
		if(now > jog){
			cout<<now<<'\n';
			for(int i = 1;i <= n;i++){
				for(int j = 1;j <= m;j++){
					cout<<p[i][j];
				}
				cout<<'\n';
			}
			continue;
		}
		// cout<<"HAHA\n";
		cout<<jog<<'\n';
		for(int i = 1;i <= n;i++){
			for(int j = 1;j <= m;j++){
				if(c[j][i] == '-') cout<<"+";
				else cout<<"-";
			}
			cout<<'\n';
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Incorrect 3 ms 492 KB Wrong answer in test 38 5: 40 < 41
# Verdict Execution time Memory Grader output
1 Correct 38 ms 1516 KB Output is correct
2 Correct 34 ms 2924 KB Output is correct
3 Correct 32 ms 3052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 1644 KB in the table A+B is not equal to 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Incorrect 3 ms 492 KB Wrong answer in test 38 5: 40 < 41