Submission #169137

# Submission time Handle Problem Language Result Execution time Memory
169137 2019-12-18T15:05:07 Z Nodir_Bobiev Red-blue table (IZhO19_stones) C++14
0 / 100
83 ms 1416 KB
# include <bits/stdc++.h>
# define FILE
using namespace std;

int main(){

	# ifdef FILEs
		freopen( "input.txt", "r", stdin );
		freopen( "output.txt", "w", stdout );
	# endif
	ios_base::sync_with_stdio( false );
	int t;
	cin >> t;
	while( t -- ){
		int n, m;
		cin >> n >> m;
		char a[n][m];
		int ans = 0;
		if( n < m ){

			ans = m ;
			for( int i = 0; i < n; i ++ ){
				for( int j = 0; j < m; j ++ ){
					a[i][j] = '-';
				}
			}

			int cnt[m] = {}, mn = 0, cnt1 = m;

			for( int i = 0; i < n; i ++ ){
				int q1 = m/2+1;
				for( int j = 0; j < m; j ++ ){
					if( !q1 )break;
					if( cnt[j] == mn ){
						a[i][j] = '+';
						cnt[j] ++;
						cnt1--;
						q1--;
						if( !cnt1 ){
							cnt1 = m;
							mn++;
							if( mn == (n-1)/2 ){
								mn = -1;
								break;
							}
						}
					}
				}
				for( int j = 0; j < m; j ++ ){
					if( !q1 )break;
					if( cnt[j] == mn ){
						a[i][j] = '+';
						cnt[j] ++;
						cnt1--;
						q1--;
						if( !cnt1 ){
							cnt1 = m;
							mn++;
							if( mn == (n-1)/2 ){
								mn = -1;
								break;
							}
						}
					}
				}
				if( q1 == 0 )
					ans ++;
				if( mn == -1 )
					break;
			}
		}
		else{

			ans = n ;
			for( int i = 0; i < n;  i++ ){
				for( int j = 0; j < m; j ++ ){
					a[i][j] = '+';
				}
			}

			int cnt[n] = {}, mn = 0, cnt1 = n;

			for( int j = 0; j < m; j ++ ){
				int q1 = n/2+1;
				for( int i = 0; i < n; i ++ ){
					if( !q1 )break;
					if( cnt[i] == mn ){
						a[i][j] = '-';
						cnt[i]++;
						cnt1--;
						q1--;
						if( !cnt1 ){
							cnt1 = n;
							mn++;
							if( mn == (m-1)/2 ){
								mn = -1;
								break;
							}
						}
					}
				}
				for( int i = 0; i < n; i ++ ){
					if( !q1 )break;
					if( cnt[i] == mn ){
						a[i][j] = '-';
						cnt[i]++;
						cnt1--;
						q1--;
						if( !cnt1 ){
							cnt1 = n;
							mn++;
							if( mn == (m-1)/2 ){
								mn = -1;
								break;
							}
						}
					}
				}
				if( q1 == 0 )
					ans ++;
				if( mn == -1 )
					break;
			}
		}

		cout << ans << endl;
		for( int i = 0; i < n; i ++ ){
			for( int j = 0; j < m; j ++ ){
				cout << a[i][j];
			}cout << endl;
		}

	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB in the table A+B is not equal to 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 376 KB in the table A+B is not equal to 3
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB in the table A+B is not equal to 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 83 ms 1416 KB in the table A+B is not equal to 78
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 1388 KB in the table A+B is not equal to 2
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB in the table A+B is not equal to 4
2 Halted 0 ms 0 KB -