답안 #343683

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
343683 2021-01-04T11:36:14 Z mglstew Red-blue table (IZhO19_stones) C++17
100 / 100
81 ms 3308 KB
#include <bits/stdc++.h>
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define N 100005
#define ccin cin >>
#define ccout cout <<
 
using namespace std;

char a[2000][2000];
int col[2000];
int row[2000];
     
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int t;
    ccin t;
    while(t--){
    	int n, m;
    	ccin n >> m;
    	int ans = max(n, m);
    	if(n > m){
    		for(int i = 0; i < n; i++){
    			for(int j = 0; j < m; j++){
    				a[i][j] = '+';
    				row[i] = m;
    			}
    		}
    		int cnt = 0;
    		for(int i = 0; i < m; i++){
    			int l = 0;
    			for(int j = 0; j < n; j++){
    				if(l >= n / 2 + 1){
    					break;
    				}
    				if(row[cnt] - 1 >= m / 2 + 1){
    					a[cnt][i] = '-';
    					row[cnt]--;
    					l++;
    				}
    				cnt++;
    				cnt %= n;
    			}
    			if(l == n / 2 + 1){
    				ans++;
    			}
    		}
    			
    	}
    	else{
    		for(int i = 0; i < n; i++){
    			for(int j = 0; j < m; j++){
    				a[i][j] = '-';
    				col[j] = n;
    			}
    		}
    		int cnt = 0;
    		for(int i = 0; i < n; i++){
    			int l = 0;
    			for(int j = 0; j < m; j++){
    				if(l >= m / 2 + 1){
    					break;
    				}
    				if(col[cnt] - 1 >= n / 2 + 1){
    					a[i][cnt] = '+';
    					col[cnt]--;
    					l++;
    				}
    				cnt++;
    				cnt %= m;
    			}
    			if(l == m / 2 + 1){
    				ans++;
    			}
    		}
    	}
    	ccout ans << endl;
    	for(int i = 0; i < n; i++){
    		for(int j = 0; j < m; j++){
    			ccout a[i][j];
    		}
    		ccout endl;
    	}
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 11 ms 492 KB Output is correct
4 Correct 18 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 1548 KB Output is correct
2 Correct 38 ms 2796 KB Output is correct
3 Correct 35 ms 3052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 1644 KB Output is correct
2 Correct 35 ms 2668 KB Output is correct
3 Correct 31 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 11 ms 492 KB Output is correct
4 Correct 18 ms 492 KB Output is correct
5 Correct 81 ms 1548 KB Output is correct
6 Correct 38 ms 2796 KB Output is correct
7 Correct 35 ms 3052 KB Output is correct
8 Correct 57 ms 1644 KB Output is correct
9 Correct 35 ms 2668 KB Output is correct
10 Correct 31 ms 2284 KB Output is correct
11 Correct 49 ms 620 KB Output is correct
12 Correct 33 ms 2668 KB Output is correct
13 Correct 37 ms 2924 KB Output is correct
14 Correct 27 ms 2540 KB Output is correct
15 Correct 40 ms 3308 KB Output is correct
16 Correct 31 ms 2668 KB Output is correct
17 Correct 14 ms 2028 KB Output is correct