답안 #231042

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
231042 2020-05-12T12:31:43 Z jamielim Red-blue table (IZhO19_stones) C++14
0 / 100
10 ms 1536 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)/(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(2*(m-l)>=m&&2*(m-u)>=m)a=n;
			else if(2*(m-l)>=m)a=max(n/2,n-(i*halfh)%n);
			else a=n/2;
			if(i+a>ans){
				ans=i+a;
				b=i;
				if(a==n/2)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);
   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB in the table A+B is not equal to 6
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB in the table A+B is not equal to 46
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB in the table A+B is not equal to 6
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1536 KB in the table A+B is not equal to 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1536 KB in the table A+B is not equal to 48
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB in the table A+B is not equal to 6