Submission #168180

# Submission time Handle Problem Language Result Execution time Memory
168180 2019-12-11T19:57:01 Z munhorgil Red-blue table (IZhO19_stones) C++14
0 / 100
102 ms 1440 KB
#include<bits/stdc++.h>

#define pb push_back

using namespace std;

int main()
{
	int n , m , i , j , t , a , b , ans;
	vector < char > temp;
	vector < vector < char > > A;
	
	cin >> t;
	
	while(t > 0)
	{
		cin >> n >> m;
		
		A.clear();
		
		for(i = 0 ; i < n ; i++)
		{
			temp.clear();
			for(j = 0 ; j < m ; j++)
			{
				temp.pb('+');
			}
			A.pb(temp);
		}
		
		if(min(n , m) > 6)
		{
			if(n % 2 == 0) a = n - 2;
				else a = n - 1;
			if(m % 2 == 0) b = m - 2;
				else b = m - 1;
				
			ans = a + b;
				
			for(i = 0 ; i < a / 2 ; i++)
			{
				for(j = 0 ; j < b / 2 ; j++)
				{
					A[i][j] = '-';
					A[i + a / 2][j + b / 2] = '-';
				}
			}
			
			for(i = a ; i < n ; i++)
			{
				for(j = 0 ; j < m ; j++)
				{
					A[i][j] = '-';
				}
			}
		}
		else
		{
			if(min(n , m) < 5)
			{
				ans = max(n , m) + (min(n , m) - 1) / 2;
				
				if(n < m)
				{
					for(i = 0 ; i < n - ((n - 1) / 2) ; i++)
					{
						for(j = 0 ; j < m ; j++)
						{
							A[i][j] = '-';
						}
					}
				}
				else
				{
					for(i = 0 ; i < n ; i++)
					{
						A[i][m - 1] = '-';
					}
				}
			}
			else
			{
				ans = n + m - min(n , m) / 2;
				
				if(n < m)
				{
					a = n - n / 2;
					
					for(i = 0 ; i < a ; i++)
					{
						for(j = (m / a) * i ; j < (m / a) * (i + 1) ; j++)
						{
							A[i][j] = '-';
						}
					}
					for(j = (m / a) * a ; j < m ; j++)
					{
						A[a - 1][j] = '-';
					}
					for(i = a ; i < n ; i++)
					{
						for(j = 0 ; j < m ; j++)
						{
							A[i][j] = '-';
						}
					}
				}
				else
				{
					b = m - m / 2;
					
					for(i = 0 ; i < n ; i++)
					{
						for(j = 0 ; j < b ; j++)
						{
							A[i][j] = '-';
						}
					}
					for(i = 0 ; i < b ; i++)
					{
						for(j = (n / b) * i ; j < (n / b) * (i + 1) ; j++)
						{
							A[j][i] = '+';
						}
					}
					for(i = (n / b) * b ; i < n ; i++)
					{
						A[i][b - 1] = '+';
					}
				}
			}
		}
		
		cout << ans << endl;
		
		for(i = 0 ; i < n ; i++)
		{
			for(j = 0 ; j < m ; j++)
			{
				cout << A[i][j];
			}
			cout << endl;
		}
		
		t--;
	}
	
	
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB in the table A+B is not equal to 2
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 376 KB in the table A+B is not equal to 2
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB in the table A+B is not equal to 2
# Verdict Execution time Memory Grader output
1 Incorrect 102 ms 1440 KB in the table A+B is not equal to 87
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 1420 KB in the table A+B is not equal to 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB in the table A+B is not equal to 2