Submission #712808

# Submission time Handle Problem Language Result Execution time Memory
712808 2023-03-20T06:09:03 Z willychan Red-blue table (IZhO19_stones) C++14
100 / 100
39 ms 2292 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds

bool arr[1005][1005];
 
void solve(){
	memset(arr,0,sizeof(arr));
	int n,m;cin>>n>>m;
	if(n>m){
		int k = m-(m/2)-1;
		int total = k*n/((n/2)+1);
		int p=0;
		for(int i=0;i<n;i++){
			for(int g=0;g<k;g++){
				arr[i][p]=1;
				p = (p+1)%total;
			}
		}
		cout<<n+total<<"\n";
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(arr[i][j]) cout<<"-";
				else cout<<"+";
			}
			cout<<"\n";
		}
	}else{
		int k = n-(n/2)-1;
		int total = k*m/((m/2)+1);
		int p=0;
		for(int i=0;i<m;i++){
			for(int g=0;g<k;g++){
				arr[p][i]=1;
				p = (p+1)%total;
			}
		}
		cout<<m+total<<"\n";
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(arr[i][j]) cout<<"+";
				else cout<<"-";
			}
			cout<<"\n";
		}
	}
}
 
int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int t;cin>>t;
	while(t--){
		solve();
	}
 
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 8 ms 1236 KB Output is correct
4 Correct 15 ms 1340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 2272 KB Output is correct
2 Correct 26 ms 2196 KB Output is correct
3 Correct 19 ms 2084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2284 KB Output is correct
2 Correct 22 ms 2132 KB Output is correct
3 Correct 20 ms 1996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 8 ms 1236 KB Output is correct
4 Correct 15 ms 1340 KB Output is correct
5 Correct 39 ms 2272 KB Output is correct
6 Correct 26 ms 2196 KB Output is correct
7 Correct 19 ms 2084 KB Output is correct
8 Correct 31 ms 2284 KB Output is correct
9 Correct 22 ms 2132 KB Output is correct
10 Correct 20 ms 1996 KB Output is correct
11 Correct 27 ms 1492 KB Output is correct
12 Correct 23 ms 1952 KB Output is correct
13 Correct 19 ms 2132 KB Output is correct
14 Correct 16 ms 1876 KB Output is correct
15 Correct 26 ms 2292 KB Output is correct
16 Correct 22 ms 2004 KB Output is correct
17 Correct 9 ms 1620 KB Output is correct