Submission #335827

# Submission time Handle Problem Language Result Execution time Memory
335827 2020-12-14T05:04:27 Z amunduzbaev Red-blue table (IZhO19_stones) C++14
38 / 100
41 ms 2156 KB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define int long long
#define ll long long 
#define ld long double 
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define prc(n) fixed << setprecision(n)
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1);
const int inf = 1e9+7;
const int N = 1e3+5;
int n, m, q;
char a[N][N];
void solve(){
	cin>>n>>m;
	if(n > m){
		if(n + (m-1)/2 >= (n - (n%2 ? 1:2)) + m-1) {
			for(int i=0;i<n;i++){
			for(int j=0;j<m;j++) a[i][j] = '+';
			}
			for(int i=0;i<(m-1)/2;i++){
				for(int j=0;j<n;j++) a[j][i] = '-';
			}
			cout<<n + (m-1)/2<<"\n";
		}else{
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++) a[i][j] = '+';
			}
			for(int i=0;i<m/2;i++){
				for(int j=0;j<=n/2;j++) a[j][i] = '-';
			}
			for(int i=m/2;i<m-1;i++){
				for(int j=(n/2 - (n%2 ? 0:1));j<n;j++) a[j][i] = '-';
			}
			cout<<(n - (n%2 ? 1:2)) + m-1<<"\n";
		}
	}else{
		if(m + (n-1)/2 >= (m - (m%2 ? 1:2)) + n-1){
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++) a[i][j] = '-';
			}
			for(int i=0;i<(n-1)/2;i++){
				for(int j=0;j<m;j++) a[i][j] = '+';
			}
			cout<<m + (n-1)/2<<"\n";
		}else{
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++) a[i][j] = '-';
			}
			for(int i=0;i<n/2;i++){
				for(int j=0; j<=m/2; j++) a[i][j] = '+';
			}
			for(int i=n/2;i<n-1;i++){
				for(int j=(m/2 - (m%2 ? 0:1)); j<m; j++) a[i][j] = '+';
			}
			cout<<(m - (m%2 ? 1:2)) + n-1<<"\n";
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cout<<a[i][j];
		}cout<<"\n";
	}
	return;
}

signed main(){
	fastios
	int t = 1;
	cin>>t;
	while(t--) solve();
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 2 ms 492 KB in the table A+B is not equal to 27
# Verdict Execution time Memory Grader output
1 Correct 41 ms 1516 KB Output is correct
2 Correct 32 ms 2048 KB Output is correct
3 Correct 33 ms 2156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 1516 KB in the table A+B is not equal to 45
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 2 ms 492 KB in the table A+B is not equal to 27