Submission #919531

# Submission time Handle Problem Language Result Execution time Memory
919531 2024-02-01T05:34:11 Z AnarTz Red-blue table (IZhO19_stones) C++17
0 / 100
45 ms 2388 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,i,j,maxl,addl,needed,check,q,w,plus;
        ans = 0;
        cin >> n >> m; 
        char table[n][m];
        bool bosoo;
        if (n>m)
        {
            maxl = n;
            addl = (m-(m/2+1))*n/(n-n/2+1);
            bosoo = true;
            memset(table,'+',sizeof table);
            needed = n/2+1;
        }else{
            maxl = m;
            addl = (n-(n/2+1))*m/(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;
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:11:21: warning: unused variable 'i' [-Wunused-variable]
   11 |         int ans,n,m,i,j,maxl,addl,needed,check,q,w,plus;
      |                     ^
stones.cpp:11:23: warning: unused variable 'j' [-Wunused-variable]
   11 |         int ans,n,m,i,j,maxl,addl,needed,check,q,w,plus;
      |                       ^
stones.cpp:62:17: warning: 'plus' may be used uninitialized in this function [-Wmaybe-uninitialized]
   62 |             plus++;
      |             ~~~~^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 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 1 ms 600 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 2384 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 2388 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Wrong answer
2 Halted 0 ms 0 KB -