Submission #172660

# Submission time Handle Problem Language Result Execution time Memory
172660 2020-01-02T09:46:42 Z LinusTorvaldsFan Red-blue table (IZhO19_stones) C++14
100 / 100
57 ms 3344 KB
#include <bits/stdc++.h>

using namespace std;

char f[2000][2000];

int ver[2000];
int hor[2000];


int main() {
	int t;
	cin>>t;
	for(;t;t--){
		int n,m;
		cin>>n>>m;
		int ans=max(n,m);
		if(n>m){
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					f[i][j]='+';
					hor[i]=m;
				}
			}
			int p=0;
			for(int j=0;j<m;j++){
				int t=0;
				for(int i=0;i<n;i++){
					if(t>=n/2+1)break;
					if(hor[p]-1>=m/2+1){
						f[p][j]='-';
						hor[p]--;
						t++;
					}
					p++;
					p%=n;
				}
				if(t==n/2+1)ans++;
			}
				
		} else{
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					f[i][j]='-';
					ver[j]=n;
				}
			}
			int p=0;
			for(int i=0;i<n;i++){
				int t=0;
				for(int j=0;j<m;j++){
					if(t>=m/2+1)break;
					if(ver[p]-1>=n/2+1){
						f[i][p]='+';
						ver[p]--;
						t++;
					}
					p++;
					p%=m;
				}
				if(t==m/2+1)ans++;
			}
		}
		cout<<ans<<endl;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				cout<<f[i][j];
			}
			cout<<"\n";
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 8 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 1624 KB Output is correct
2 Correct 45 ms 2808 KB Output is correct
3 Correct 43 ms 3064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 1656 KB Output is correct
2 Correct 41 ms 2552 KB Output is correct
3 Correct 38 ms 2268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 8 ms 504 KB Output is correct
5 Correct 57 ms 1624 KB Output is correct
6 Correct 45 ms 2808 KB Output is correct
7 Correct 43 ms 3064 KB Output is correct
8 Correct 50 ms 1656 KB Output is correct
9 Correct 41 ms 2552 KB Output is correct
10 Correct 38 ms 2268 KB Output is correct
11 Correct 18 ms 632 KB Output is correct
12 Correct 41 ms 2732 KB Output is correct
13 Correct 41 ms 2936 KB Output is correct
14 Correct 32 ms 2424 KB Output is correct
15 Correct 50 ms 3344 KB Output is correct
16 Correct 38 ms 2768 KB Output is correct
17 Correct 18 ms 2040 KB Output is correct