답안 #231341

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
231341 2020-05-13T11:31:06 Z jamielim Red-blue table (IZhO19_stones) C++14
42 / 100
18 ms 1920 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);
   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Incorrect 6 ms 564 KB Wrong answer in test 5 29: 31 < 32
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 1408 KB Wrong answer in test 23 57: 76 < 78
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1408 KB Output is correct
2 Correct 13 ms 1920 KB Output is correct
3 Correct 13 ms 1664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Incorrect 6 ms 564 KB Wrong answer in test 5 29: 31 < 32