Submission #336628

# Submission time Handle Problem Language Result Execution time Memory
336628 2020-12-16T04:32:27 Z Gurban Red-blue table (IZhO19_stones) C++17
32 / 100
62 ms 1900 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int maxn=1e3+5;
int tt;
int n,m,ans,b,a,tr;
char c[maxn][maxn];
priority_queue<pair<int,int>>q;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> tt;
	while(tt--){
		cin >> n >> m;
		if(min(n,m) <= 2){
			if(n >= m) for(int i = 1;i <= n;i++) for(int j = 1;j <= m;j++) c[i][j] = '+';
			else for(int i = 1;i <= n;i++) for(int j = 1;j <= m;j++) c[i][j] = '-';	
			
			cout<<max(n,m)<<'\n';
			for(int i = 1;i <= n;i++){
				for(int j = 1;j <= m;j++) cout<<c[i][j];
				cout<<'\n';
			}
			continue;
		}
		if(n < m) swap(n,m),tr=1;
		for(int i = 1;i <= n;i++)
			for(int j = 1;j <= m;j++) c[i][j] = '+';
		b = (m-1)/2;
		a = n/2+1;
		ans = n + ((n*b)/a);
		// cout<<a<<'\n';
		while(!q.empty()) q.pop();
		for(int i = 1;i <= n;i++) q.push({b,i});
		for(int i = 1;i <= m;i++){
			for(int j = 1;j <= a;j++){
				if(q.empty()) break;
				pair<int,int>x=q.top(); q.pop();
				c[x.second][i] = '-';
				if(x.first > 1) q.push({x.first-1,x.second});
			}
		}
		cout<<ans<<'\n';
		// for(int i = 1;i <= n;i++){
		// 	for(int j = 1;j <= m;j++){
		// 		cout<<c[i][j];
		// 	}
		// 	cout<<'\n';
		// }
		if(tr) swap(n,m);
		for(int i = 1;i <= n;i++){
			for(int j = 1;j <= m;j++){
				if(tr){
					if(c[j][i]=='-') c[j][i]='+';
					else c[j][i]='-';
					cout<<c[j][i];
				}
				else cout<<c[i][j];
			}
			cout<<'\n';
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Wrong answer
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 1 ms 364 KB Wrong answer
# Verdict Execution time Memory Grader output
1 Incorrect 62 ms 1516 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 60 ms 1536 KB Output is correct
2 Correct 55 ms 1900 KB Output is correct
3 Correct 50 ms 1644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 1 ms 364 KB Wrong answer