답안 #201987

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
201987 2020-02-13T01:51:25 Z guangxuan Red-blue table (IZhO19_stones) C++14
100 / 100
13 ms 2296 KB
#include <bits/stdc++.h>

using namespace std;

char ans[1002][1002];

int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		int n,m;
		scanf("%d%d",&n,&m);
		int ans1 = n + (m-1)/2, ans2 = m + (n-1)/2;
		for(int x=1;x<m;x++){
			if((n*x + (m-1)/2 + x - 1)/((m-1)/2 + x) <= (n-1)/2)ans1++;
			else break;
		}
		for(int x=1;x<n;x++){
			if((m*x + (n-1)/2 + x - 1)/((n-1)/2 + x) <= (m-1)/2)ans2++;
			else break;
		}
		printf("%d\n",max(ans1,ans2));
		if(ans1>ans2){
			int x = ans1 - (n+(m-1)/2);
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(j<x+(m-1)/2)ans[i][j]='-';
					else ans[i][j]='+';
				}
				for (int j = i * x; j< (i+1) * x; j++){
					ans[i][j%(x+(m-1)/2)] = '+';
				}
				ans[i][m] = '\0';
			}
		}
		else{
			int x = ans2 - (m+(n-1)/2);
			for(int j=0;j<m;j++){
				for(int i=0;i<n;i++){
					if(i<x+(n-1)/2)ans[i][j]='+';
					else ans[i][j]='-';
				}
				for (int i = j * x; i< (j+1) * x; i++){
					ans[i%(x+(n-1)/2)][j] = '-';
				}
			}
			for(int i=0;i<n;i++)ans[i][m]='\0';
		}
		for(int i=0;i<n;i++)printf("%s\n",ans[i]);
	}
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&T);
  ~~~~~^~~~~~~~~
stones.cpp:12: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 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 1400 KB Output is correct
2 Correct 11 ms 1912 KB Output is correct
3 Correct 11 ms 2168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1528 KB Output is correct
2 Correct 10 ms 1912 KB Output is correct
3 Correct 13 ms 1656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 13 ms 1400 KB Output is correct
6 Correct 11 ms 1912 KB Output is correct
7 Correct 11 ms 2168 KB Output is correct
8 Correct 11 ms 1528 KB Output is correct
9 Correct 10 ms 1912 KB Output is correct
10 Correct 13 ms 1656 KB Output is correct
11 Correct 7 ms 632 KB Output is correct
12 Correct 11 ms 1912 KB Output is correct
13 Correct 11 ms 2040 KB Output is correct
14 Correct 9 ms 1656 KB Output is correct
15 Correct 12 ms 2296 KB Output is correct
16 Correct 10 ms 1788 KB Output is correct
17 Correct 7 ms 1272 KB Output is correct