Submission #168183

# Submission time Handle Problem Language Result Execution time Memory
168183 2019-12-11T20:15:16 Z munhorgil Red-blue table (IZhO19_stones) C++14
69 / 100
103 ms 1948 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++)
					{
						for(j = 0 ; j < (m - 1) / 2 ; j++)
						{
							A[i][j] = '-';
						}
					}
				}
			}
			else
			{
				ans = n + m - min(n , m) / 2;
				
				if(n < m)
				{
					b = n - (n / 2);
					for(i = 0 ; i < m ; i++)
					{
						a = i % b;
						A[a][i] = '-';
					}
					for(i = b ; 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 < n ; i++)
					{
						a = i % b;
						A[i][a] = '+';
					}
				}
			}
		}
		
		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 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 14 ms 376 KB Output is correct
4 Correct 24 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 103 ms 1400 KB Output is correct
2 Correct 48 ms 1912 KB Output is correct
3 Correct 47 ms 1948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 1400 KB Output is correct
2 Correct 45 ms 1772 KB Output is correct
3 Correct 42 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 14 ms 376 KB Output is correct
4 Correct 24 ms 376 KB Output is correct
5 Correct 103 ms 1400 KB Output is correct
6 Correct 48 ms 1912 KB Output is correct
7 Correct 47 ms 1948 KB Output is correct
8 Correct 77 ms 1400 KB Output is correct
9 Correct 45 ms 1772 KB Output is correct
10 Correct 42 ms 1528 KB Output is correct
11 Incorrect 52 ms 632 KB Wrong answer in test 26 8: 30 < 31
12 Halted 0 ms 0 KB -