Submission #231333

# Submission time Handle Problem Language Result Execution time Memory
231333 2020-05-13T11:25:30 Z jamielim Red-blue table (IZhO19_stones) C++14
0 / 100
10 ms 1408 KB
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int t;
	scanf("%d",&t);
	int n,m;
	char grid[1005][1005];
	while(t--){
		scanf("%d%d",&n,&m);
		int ans=0;
		int b=0;
		bool align=0;
		int halfh=ceil((double)(n+1)/(double)2);
		for(int i=0;i<=m;i++){
			int a=0;
			int l=floor((double)(i*halfh)/(double)(n)),u=ceil((double)(i*halfh)/(double)(n));
			if(l<=m-l&&u<=m-u)a=n;
			else if(l<=m-l)a=max(n-halfh,n-(i*halfh)%n);
			else a=n-halfh;
			if(i+a>ans){
				ans=i+a;
				b=i;
				if(a==n-halfh)align=1;
				else align=0;
			}
		}
		printf("%d\n",ans);
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				grid[i][j]='+';
			}
			grid[i][m]='\0';
		}
		if(align){
			for(int i=0;i<b*halfh;i++){
				grid[i%n][i/halfh]='-';
			}
		}else{
			for(int i=0;i<b;i++){
				for(int j=0;j<halfh;j++)grid[j][i]='-';
			}
		}
		for(int i=0;i<n;i++)printf("%s\n",grid[i]);
	}
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&t);
  ~~~~~^~~~~~~~~
stones.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&n,&m);
   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB in the table A+B is not equal to 4
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 384 KB in the table A+B is not equal to 46
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB in the table A+B is not equal to 4
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1408 KB in the table A+B is not equal to 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1408 KB in the table A+B is not equal to 46
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB in the table A+B is not equal to 4