Submission #490825

#TimeUsernameProblemLanguageResultExecution timeMemory
490825erkmRed-blue table (IZhO19_stones)C++14
38 / 100
24 ms1760 KiB
#include<bits/stdc++.h>

#define loop(n) for(int i=0; i<n; i++)
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define p_b push_back
#define l_b lower_bound
#define u_b upper_bound
#define m_p make_pair
#define m_t make_tuple
#define ar array
using namespace std;
	const int M=1e9, mxN=1e5;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    //cout.tie(NULL);
    
    int T;
    cin>>T;
    while(T--){
    	int n, m, ans=0;
    	cin>>n>>m;
    	char a[n][m];
    	if(n<m){
	    	for(int i=0; i<n; i++){
	    		for(int j=0; j<m; j++){
	    			a[i][j]='-';
				}
			}
			int x=m/2+1, y=n/2-(n%2==0);
//			cout<<x<<' '<<y<<endl;
			for(int i=0; i<y; i++){
				for(int j=0; j<x; j++){
					a[i][j]='+';
				}
			}
			ans=m+y;
//			cout<<x<<' '<<abs(n-(y*2))<<endl;
			if(y>abs(m-(x*2))){
				for(int i=y; i<y+y; i++){
					for(int j=x-abs(m-(x*2)); j<x-abs(m-(x*2))+x; j++){
						a[i][j]='+';
					}
				}
				ans+=m-(x*2)+y;
			}
			cout<<ans<<'\n';
			for(int i=0; i<n; i++){
				for(int j=0; j<m; j++){
					cout<<a[i][j];
				}
				cout<<'\n';
			}

		}
    	else {
			for(int i=0; i<n; i++){
	    		for(int j=0; j<m; j++){
	    			a[i][j]='+';
				}
			}
			int x=m/2-(m%2==0), y=n/2+1;
//			cout<<x<<' '<<y<<endl;
			for(int i=0; i<y; i++){
				for(int j=0; j<x; j++){
					a[i][j]='-';
				}
			}
			ans=n+x;
//			cout<<x<<' '<<abs(n-(y*2))<<endl;
			if(x>abs(n-(y*2))){
				for(int i=y-abs(n-(y*2)); i<y-abs(n-(y*2))+y; i++){
					for(int j=x; j<x+x; j++){
						a[i][j]='-';
					}
				}
				ans+=n-(y*2)+x;
			}
			cout<<ans<<'\n';
			for(int i=0; i<n; i++){
				for(int j=0; j<m; j++){
					cout<<a[i][j];
				}
				cout<<'\n';
			}
		}

		
	}


    
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...