Submission #498852

# Submission time Handle Problem Language Result Execution time Memory
498852 2021-12-26T13:02:36 Z alimurodov Red-blue table (IZhO19_stones) C++14
27 / 100
31 ms 1220 KB
#include <bits/stdc++.h>
 
using namespace std;
 
void solve(){
	int n, m;	
    cin >> n >> m;
    
    if(n >= 3 && m >= 3){
    	if(n < m){
    		int s = m;
    		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 += n / 2;
	    		for(int i = 0; i < n / 2; i++){
	    			for(int j = 0; j < m / 2 + 1; j++){
	    				a[i][j] = '+';
	    			}
	    		}
			}else if(n % 2 && m % 2 == 0){
    			s += n / 2;
	    		for(int i = 0; i < n / 2; i++){
	    			for(int j = 0; j < m / 2 + 1; j++){
	    				a[i][j] = '+';
	    			}
	    		}
			}else if(n % 2 == 0 && m % 2){
    			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] = '+';
	    			}
	    		}
			} else{
				s += n / 2;
				for(int i = 0; i < n / 2; 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{
			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;
	    		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 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Incorrect 4 ms 344 KB in the table A+B is not equal to 26
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 1220 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Incorrect 4 ms 344 KB in the table A+B is not equal to 26