제출 #1133147

#제출 시각아이디문제언어결과실행 시간메모리
1133147michael12Red-blue table (IZhO19_stones)C++20
0 / 100
16 ms1352 KiB
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int T;
    cin >> T;  // Number of test cases
    
    while (T--) {
        int N, M;
        cin >> N >> M;  // Dimensions of the table
        
        // Initialize the table with an empty string
        vector<string> table(N);
        
        if(M==1 || N==1){
            if(N==1){
                cout<<M<<endl;
                for(int i=1; i<=M; i++){
                    cout<<"-";
                }
                cout<<endl;
            }
            else
            {
                cout<<N<<endl;
                for(int i=1; i<=N; i++){
                    cout<<"+"<<endl;
                }
                cout<<endl;
            }
        }
        else
        {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < M; ++j) {
                if ((i + j) % 2 == 0) {
                    table[i] += '+';  // Red stone
                } else {
                    table[i] += '-';  // Blue stone
                }
            }
        }
        
        // Calculate A + B
        int A = N / 2 + (N % 2);  // Rows Aidos likes (more '+' than '-')
        int B = M / 2 + (M % 2);  // Columns Tima likes (more '-' than '+')
        
        cout << A + B << endl;  // Output the maximum A + B
        
        // Output the table
        for (const auto& row : table) {
            cout << row << endl;
        }
    }
    }
    
    return 0;
}
#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...