Submission #919533

# Submission time Handle Problem Language Result Execution time Memory
919533 2024-02-01T05:40:58 Z AnarTz Red-blue table (IZhO19_stones) C++17
0 / 100
47 ms 2384 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
int main() {
    long long t;
    cin >> t;

    while (t--) {
        int ans,n,m,maxl,addl,needed,check,q,w,plus=0;
        ans = 0;
        cin >> n >> m; 
        char table[n][m];
        bool bosoo;
        if (n>m)
        {
            maxl = n;
            addl = ((m-(m/2+1))*n)/(n/2+1);
            bosoo = true;
            memset(table,'+',sizeof table);
            needed = n/2+1;
        }else{
            maxl = m;
            addl = ((n-(n/2+1))*m)/(m/2+1);
            bosoo = false;
            memset(table,'-',sizeof table);
            needed = m/2+1;
        }
        ans = maxl + addl;
        cout << ans<<endl;
        check = needed*addl;
        q=0;
        w=0;
        
        while (check>0 && bosoo == false)
        {
            
            table[q][w]='+';
            w++;
            check--;
            plus++;
            if (plus==maxl/2+1)
            {
                q++;
                plus=0;
            }
            if (w==maxl)
            {
                w=0;        
            }
            
                
            
        }
        while (check>0 && bosoo == true)
        {
            
            table[w][q]='-';
            w++;
            check--;
            plus++;
            if (plus==maxl/2+1)
            {
                q++;
                plus=0;
            }
            if (w==maxl)
            {
                w=0;        
            }
            
                
            
        }













        for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cout << table[i][j] << ' ';
        }
        cout << '\n';
    }
        
        
        






















    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 2384 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 2224 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong answer
2 Halted 0 ms 0 KB -