Submission #168182

#TimeUsernameProblemLanguageResultExecution timeMemory
168182munhorgilRed-blue table (IZhO19_stones)C++14
27 / 100
37 ms1272 KiB
#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)
				{
					for(i = 0 ; i < m ; i++)
					{
						a = i % 3;
						A[a][i] = '-';
					}
					for(i = 3 ; i < n ; i++)
					{
						for(j = 0 ; j < m ; j++)
						{
							A[i][j] = '-';
						}
					}
				}
				else
				{
					for(i = 0 ; i < n ; i++)
					{
						for(j = 0 ; j < b ; j++)
						{
							A[i][j] = '-';
						}
					}
					for(i = 0 ; i < n ; i++)
					{
						a = i % 3;
						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--;
	}
	
	
}

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:9:30: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
  int n , m , i , j , t , a , b , ans;
                              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...