답안 #167719

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167719 2019-12-09T19:03:33 Z munhorgil Red-blue table (IZhO19_stones) C++14
11 / 100
93 ms 1272 KB
#include<bits/stdc++.h>

using namespace std;

int main()
{
	int t , i , j , m , n , ans , a , b;
	
	cin >> t;
	
	while(t > 0)
	{
		cin >> n >> m;
		
		if(n > 2)
		{
			if(n % 2 == 0) a = n - 2;
				else a = n - 1;	
		}
		if(m > 2)
		{
			if(m % 2 == 0) b = m - 2;
			else b = m - 1;
		}
		
		if(n == 1)
		{
			a = 0;
			cout << m << endl;
			goto here;
		}
		if(m == 1)
		{
			cout << n << endl;
			for(i = 0 ; i < n ; i++)
			{
				cout << "+" << endl;
			}
			goto there;
		}
		if(n == 2)
		{
			a = 0;
			cout << m << endl;
			goto here;
		}
		if(m == 2)
		{
			cout << n << endl;
			for(i = 0 ; i < n ; i++)
			{
				cout << "++" << endl;
			}
			goto there;
		}
		
		ans = a + b;
		
		cout << ans << endl;
		
		for(j = 0 ; j < a / 2 ; j++)
		{
			for(i = 0 ; i < b / 2 ; i++)
			{
				cout << "+";
			}
			for(i = 0 ; i < b / 2 ; i++)
			{
				cout << "-";
			}
			for(i = 0 ; i < (m - b) ; i++)
			{
				cout << "+";
			}
			cout << endl;
		}
		for(j = 0 ; j < a / 2 ; j++)
		{
			for(i = 0 ; i < b / 2 ; i++)
			{
				cout << "-";
			}
			for(i = 0 ; i < b / 2 ; i++)
			{
				cout << "+";
			}
			for(i = 0 ; i < (m - b) ; i++)
			{
				cout << "+";
			}
			cout << endl;
		}
		here:;
		for(j = 0 ; j < (n - a) ; j++)
		{
			for(i = 0 ; i < m ; i++)
			{
				cout << "-";
			}
			cout << endl;
		}
		
		there:;
		
		t--;
	}
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:87:23: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
    for(i = 0 ; i < (m - b) ; i++)
                    ~~~^~~~
stones.cpp:61:21: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
   for(j = 0 ; j < a / 2 ; j++)
                   ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 380 KB Wrong answer in test 4 4: 4 < 5
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 376 KB Wrong answer in test 4 3: 4 < 5
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 380 KB Wrong answer in test 4 4: 4 < 5
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 1272 KB Output is correct
2 Correct 40 ms 1144 KB Output is correct
3 Correct 39 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 67 ms 1272 KB Wrong answer in test 4 4: 4 < 5
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 380 KB Wrong answer in test 4 4: 4 < 5