답안 #490795

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
490795 2021-11-29T10:00:07 Z Abdurahmon Red-blue table (IZhO19_stones) C++14
100 / 100
144 ms 2244 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int t;
cin>>t;
while(t--)
{
	int a,b;
	cin>>a>>b;
	bool ss=0;
	if(a>b)
	{
		ss=1;
		swap(a,b);
	}
	char aa[a][b];
	map<int,int>a1,b1;
	int e=(a-1)/2,	h=b/2+1;
	int mxx = 0;
	for(int c=0;c<a;c++)
	{
		int mx=mxx, h1=h;
		for(int i=0;i<b;i++)
		{
			if(a1[i]<e){
				if(h1!=0){
					if(b-i==h1 || a1[i]<mx)
						aa[c][i]='+', h1--, a1[i]++, b1[c]++;
					else
						aa[c][i]='-';
				}
				else
					aa[c][i]='-';
			}
			else
				aa[c][i]='-';
			mxx = max(mxx, a1[i]);
		}
	}
	int ans=0;
	for(int c=0; c<a; c++)
		if(b1[c]==h)
			ans++;
	cout << ans+b << "\n";
	if(ss)
	{
		for(int c=0;c<b;c++)
		{
			for(int i=0;i<a;i++)
			{
				if(aa[i][c]=='-')
					cout << '+';
				else
					cout << '-';
			}
			cout<<"\n";
		}
	}
	else
	{
			for(int c=0;c<a;c++)
		{
			for(int i=0;i<b;i++)
			{
				cout<<aa[c][i];
			}
			cout<<"\n";
		}
		
	}
	
}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 4 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 1232 KB Output is correct
2 Correct 125 ms 1900 KB Output is correct
3 Correct 118 ms 1808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 1284 KB Output is correct
2 Correct 104 ms 1596 KB Output is correct
3 Correct 106 ms 1412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 4 ms 332 KB Output is correct
5 Correct 85 ms 1232 KB Output is correct
6 Correct 125 ms 1900 KB Output is correct
7 Correct 118 ms 1808 KB Output is correct
8 Correct 88 ms 1284 KB Output is correct
9 Correct 104 ms 1596 KB Output is correct
10 Correct 106 ms 1412 KB Output is correct
11 Correct 15 ms 452 KB Output is correct
12 Correct 105 ms 1544 KB Output is correct
13 Correct 108 ms 1392 KB Output is correct
14 Correct 77 ms 1100 KB Output is correct
15 Correct 144 ms 2244 KB Output is correct
16 Correct 102 ms 1828 KB Output is correct
17 Correct 42 ms 912 KB Output is correct