Submission #498807

# Submission time Handle Problem Language Result Execution time Memory
498807 2021-12-26T11:56:46 Z alimurodov Red-blue table (IZhO19_stones) C++14
0 / 100
32 ms 1192 KB
#include <bits/stdc++.h>

using namespace std;

void solve(){
	int n, m;	
    cin >> n >> m;
    
    if(n >= 3 && m >= 3){
    		int s = n;
    		char a[100][100];
    		for(int i = 0; i < n; i++){
    			for(int j = 0; j < m; j++){
    				a[i][j] = '+';
    			}
    		}
    		
    		if(n % 2 && m % 2){
    			s += m / 2;
	    		for(int i = 0; i < n / 2 + 1; i++){
	    			for(int j = 0; j <= m / 2 - 1; j++){
	    				a[i][j] = '-';
	    			}
	    		}
			}else if(n % 2 && m % 2 == 0){
    			s += m / 2 - 1;
	    		for(int i = 0; i < n / 2 + 1; i++){
	    			for(int j = 0; j < m / 2 - 1; j++){
	    				a[i][j] = '-';
	    			}
	    		}
			}else if(n % 2 == 0 && m % 2){
    			s += m / 2 - 1;
	    		for(int i = 0; i < n / 2 + 1; i++){
	    			for(int j = 0; j < m / 2; j++){
	    				a[i][j] = '-';
	    			}
	    		}
			} else{
				s += n / 2 - 1;
				for(int i = 0; i < n / 2 + 1; i++){
	    			for(int j = 0; j < m / 2 - 1; j++){
	    				a[i][j] = '-';
	    			}
	    		}
			}
    		cout << s << '\n';
    		for(int i = 0; i < n; i++){
    			for(int j = 0; j < m; j++){
    				cout << a[i][j];
    			}
    			cout << '\n';
    	}	
    } else{
    	if(n < m){
    		cout << m << '\n';
    		for(int i = 0; i < n; i++){
    			for(int j = 0; j < m; j++){
    				cout << '-';
    			}
    			cout << '\n';
    		}
    	} else{	
    		cout << n << '\n';
    		for(int i = 0; i < n; i++){
    			for(int j = 0; j < m; j++){
    					cout << '+';
    				}
    				cout << '\n';
    			}
    	}
    }
}

int main(){
    int t;
    cin >> t;
    
    while(t--)
    	solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB in the table A+B is not equal to 4
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 204 KB Wrong answer in test 3 45: 25 < 46
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB in the table A+B is not equal to 4
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 1192 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB in the table A+B is not equal to 4