답안 #837941

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
837941 2023-08-25T21:02:25 Z MODDI Red-blue table (IZhO19_stones) C++14
27 / 100
42 ms 1344 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
// 3 3
// -++
// +-+
// -++
// wlog N > M
// every row will have N/2+1 red stones
// then make rows
int main(){
	int t;
	cin>>t;
	while(t--){
		int n, m;
		cin>>n>>m;
		int ans = 0;
		char mat[n][m];
		if(n >= m){
			int minus[m];
			memset(minus, 0, sizeof minus);
			for(int i = 0; i < n; i++){
				int need = m/2 + 1;
				for(int j = 0; j < m; j++){
					if(minus[j] < n/2+1 && (m-j-1) >= need){
						minus[j]++;
						mat[i][j] = '-';
					}
					else{
						mat[i][j] = '+';
						need--;
					}
				}
				ans++;
			}
			for(int i = 0; i < m; i++){
				if(minus[i] >= n/2+1)	ans++;
			}
			cout<<ans<<"\n";
			for(int i = 0; i < n; i++){
				for(int j = 0; j < m; j++)
					cout<<mat[i][j];
				cout<<endl;
			}
		}
		else{
			int plus[n];
			memset(plus, 0, sizeof plus);
			for(int j = 0; j < m; j++){
				int need = n/2 + 1;
				for(int i = 0; i < n; i++){
					if(plus[i] < m/2+1 && (n - i - 1) >= need){
						mat[i][j] = '+';
						plus[i]++;
					}
					else{
						mat[i][j] = '-';
						need--;
					}
				}
				ans++;
			}
			for(int i = 0; i < n; i++)
				if(plus[i] >= m / 2 + 1)	ans++;
				
			cout<<ans<<"\n";
			for(int i = 0; i < n; i++){
				for(int j = 0; j < m; j++)
					cout<<mat[i][j];
				cout<<endl;
			}
		}
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 5 ms 300 KB Output is correct
4 Incorrect 9 ms 340 KB Wrong answer in test 5 29: 31 < 32
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 42 ms 1212 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 32 ms 1344 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 300 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 5 ms 300 KB Output is correct
4 Incorrect 9 ms 340 KB Wrong answer in test 5 29: 31 < 32
5 Halted 0 ms 0 KB -