Submission #1230741

#TimeUsernameProblemLanguageResultExecution timeMemory
1230741altern23Red-blue table (IZhO19_stones)C++20
27 / 100
22 ms1352 KiB
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pii pair<ll, ll>
#define fi first
#define sec second
#define ld long double

const int MAXN = 1e5;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
	int tc = 1;	
	cin >> tc;
	for(;tc--;){
		ll N, M; cin >> N >> M;
		vector<ll> cur(M + 5, N);
		ll ans = M;
		ll rows = M, pt = 0;
		for(int i = 1; i <= N; i++){
			sort(cur.begin() + 1, cur.begin() + 1 + M);
			for(int j = 1; j <= M / 2 + 1; j++){
				cur[j]--;
				if(cur[j] == N / 2) rows--;
			}
			if(ans < rows + i){
				ans = rows + i;
				pt = i;
			}
		}
		
		vector<vector<char>> grid(N + 5, vector<char>(M + 5));
		for(int i = 1; i <= N; i++){
			for(int j = 1; j <= M; j++) grid[i][j] = '-';
		}
		vector<pii> now;
		for(int i = 1; i <= M; i++) now.push_back({N, i});
		for(int i = 1; i <= pt; i++){
			sort(now.begin(), now.end());
			for(int j = 0; j < M / 2 + 1; j++){
				grid[i][now[j].sec] = '+';
				now[j].fi--;
			}
		}
		
		cout << ans << "\n";
		for(int i = 1; i <= N; i++){
			for(int j = 1; j <= M; j++) cout << grid[i][j];
			cout << "\n";
		}
	}
}

/*

*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...