Submission #372338

# Submission time Handle Problem Language Result Execution time Memory
372338 2021-02-27T17:24:14 Z mariowong Red-blue table (IZhO19_stones) C++14
53 / 100
39 ms 3052 KB
#include <bits/stdc++.h>
using namespace std;

int t,n,m,pos,num,anss1,anss2,ct1[1005],ct2[1005];
char ans1[1005][1005],ans2[1005][1005];
int main(){
	ios::sync_with_stdio(false);
	cin >> t;
	while (t--){
		cin >> n >> m;
		for (int i=1;i<=n;i++){
			for (int j=1;j<=m;j++){
				ans1[i][j]='+';
			}
			ct1[i]=0;
		}
		pos=1; anss1=n;
		for (int i=1;i<=(n-1)/2*m/(n/2+1);i++){
			for (int j=1;j<=n/2+1;j++){
				if (ct1[pos]+1 >= (m+1)/2)
				goto out;
				ans1[pos][i]='-';
				ct1[pos]++;
				pos++; 
				if (pos == n+1)
				pos=1;
			}	
			anss1++;
		}
		out:;
		for (int i=1;i<=n;i++){
			for (int j=1;j<=m;j++){
				ans2[i][j]='-';
				ct2[j]=0;
			}
		}
		pos=1; anss2=m;
		for (int i=1;i<=(m-1)/2*n/(m/2+1);i++){
			for (int j=1;j<=m/2+1;j++){
				if (ct2[pos]+1 >= (n+1)/2)
				goto out2;
				ans2[i][pos]='+';
				ct2[pos]++;
				pos++; 
				if (pos == m+1)
				pos=1;
			}
			anss2++;	
		}
		out2:;
		cout << max(anss1,anss2) << "\n";
		if (anss1 > anss2){
			for (int i=1;i<=n;i++){
				for (int j=1;j<=m;j++){
					cout << ans1[i][j];
				}
				cout << "\n";
			}
		}
		else
		{
			for (int i=1;i<=n;i++){
				for (int j=1;j<=m;j++){
					cout << ans2[i][j];
				}
				cout << "\n";
			}
		}
	}
    return 0;
}	
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Incorrect 4 ms 492 KB Wrong answer in test 6 5: 8 < 9
# Verdict Execution time Memory Grader output
1 Correct 39 ms 1644 KB Output is correct
2 Correct 33 ms 2796 KB Output is correct
3 Correct 31 ms 3052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 1644 KB Output is correct
2 Correct 37 ms 2668 KB Output is correct
3 Correct 28 ms 2284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Incorrect 4 ms 492 KB Wrong answer in test 6 5: 8 < 9