Submission #908446

# Submission time Handle Problem Language Result Execution time Memory
908446 2024-01-16T12:18:33 Z SalihSahin Red-blue table (IZhO19_stones) C++14
11 / 100
40 ms 2020 KB
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
using namespace std;
 
const int mod = 1e9 + 7;
const int inf = 1e12*2;
const int N = 2e5 + 5;
 
int32_t main(){
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--){
        int n, m;
        cin>>n>>m;

        if(n%2 == 1 && m%2 == 1){
            if(n == 1){
                cout<<m<<endl;
                for(int i = 0; i < m; i++){
                    cout<<"-";
                }
                cout<<endl;
            }
            else if(m == 1){
                cout<<n<<endl;
                for(int i = 0; i < n; i++){
                    cout<<"+"<<endl;
                }
            }
            else{
                cout<<n + m - 2<<endl;
                vector<vector<char> > a(n, vector<char>(m, '-'));
                for(int i = 0; i < n/2; i++){
                    for(int j = 0; j < m/2; j++){
                        a[i][j] = '+';
                        a[n - i - 1][m - j - 1] = '+';
                    }
                }
                for(int i = 0; i < n; i++){
                    a[i][m/2] = '+';
                }

                for(int i = 0; i < n; i++){
                    for(int j = 0; j < m; j++){
                        cout<<a[i][j];
                    }
                    cout<<endl;
                }
            }
        }
        else{
            int bcol = m - ((m+1) / 2), rrow = n - ((n+1)/2);

            if(n + bcol > m + rrow){
                cout<<n+bcol<<endl;
                vector<vector<char> > a(n, vector<char>(m, '+'));
                for(int i = 0; i < n; i++){
                    for(int j = 0; j < bcol; j++){
                        a[i][j] = '-';
                    }
                }

                for(int i = 0; i < n; i++){
                    for(int j = 0; j < m; j++){
                        cout<<a[i][j];
                    }
                    cout<<endl;
                }
            }
            else{
                cout<<m+rrow<<endl;
                vector<vector<char> > a(n, vector<char>(m, '-'));
                for(int i = 0; i < rrow; i++){
                    for(int j = 0; j < m; j++){
                        a[i][j] = '+';
                    }
                }

                for(int i = 0; i < n; i++){
                    for(int j = 0; j < m; j++){
                        cout<<a[i][j];
                    }
                    cout<<endl;
                }
            }
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB in the table A+B is not equal to 2
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 348 KB in the table A+B is not equal to 2
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB in the table A+B is not equal to 2
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 40 ms 1296 KB Output is correct
2 Correct 17 ms 1628 KB Output is correct
3 Correct 18 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 1404 KB in the table A+B is not equal to 36
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB in the table A+B is not equal to 2
3 Halted 0 ms 0 KB -