답안 #683386

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
683386 2023-01-18T10:06:59 Z Onur_Ilgaz Red-blue table (IZhO19_stones) C++17
100 / 100
22 ms 2196 KB
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long
#define inf 1e18
using namespace std;
bool grid[1001][1001];

void solve(){
	int n, m;
	cin>>n>>m;
	bool whobig=n>m;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			grid[i][j]=whobig; //1 + demek, 0 -
		}
	}
	int k=(min(n, m)-1)/2, sutun=1, satir=1, cnt=0;
	int ans=0;
	for(int i=1; i<=k; i++){
		if(whobig){ //satır sayısı sütun sayısından fazla ise
			for(int j=1; j<=n; j++){
				grid[j][sutun]=0;
				cnt++;
				if(cnt == n/2+1){
					cnt=0;
					sutun++;
					ans++;
				}
			}
		}
		else{
			for(int j=1; j<=m; j++){
				grid[satir][j]=1;
				cnt++;
				if(cnt == m/2+1){
					cnt=0;
					satir++;
					ans++;
				}
			}
		}
	}
	ans+=max(n, m);
	cout<<ans<<"\n";
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			if(grid[i][j]){
				cout<<'+';
			}
			else cout<<'-';
		}
		cout<<"\n";
	}
}

int32_t main(){
	fast
	#ifdef Local
    freopen("in","r",stdin);
    freopen("out","w",stdout);
    #endif
	int t=1;
	cin>>t;
	while(t--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1396 KB Output is correct
2 Correct 18 ms 1892 KB Output is correct
3 Correct 18 ms 2088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 1420 KB Output is correct
2 Correct 18 ms 1748 KB Output is correct
3 Correct 16 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 22 ms 1396 KB Output is correct
6 Correct 18 ms 1892 KB Output is correct
7 Correct 18 ms 2088 KB Output is correct
8 Correct 21 ms 1420 KB Output is correct
9 Correct 18 ms 1748 KB Output is correct
10 Correct 16 ms 1536 KB Output is correct
11 Correct 7 ms 596 KB Output is correct
12 Correct 17 ms 1804 KB Output is correct
13 Correct 19 ms 2004 KB Output is correct
14 Correct 14 ms 1608 KB Output is correct
15 Correct 22 ms 2196 KB Output is correct
16 Correct 16 ms 1748 KB Output is correct
17 Correct 8 ms 1236 KB Output is correct