Submission #744555

# Submission time Handle Problem Language Result Execution time Memory
744555 2023-05-18T18:03:40 Z Andrei Red-blue table (IZhO19_stones) C++17
0 / 100
11 ms 724 KB
#include <bits/stdc++.h>

using namespace std;

/**
clin[i]
ccol[j]

a + b

n + m

n,m sunt impare
n + (m-1)/2

n = m

lin,col

+-+
+-+
+++

++-
++-
++-

*/

int t;
int n,m;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>t;
    while(t--)
    {
        cin>>n>>m;
        if(n%2==1 && m%2==1)
        {
            cout<<max(n+(m-1)/2,m+(n-1)/2)<<"\n";
            continue;
        }
        int maxim=0;
        int anslin;
        int anscol;
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=m; j++)
            {
                int aux=0;
                if(j>m-j)
                    aux+=i;
                aux+=m-j;
                if(i<n-i)
                    aux+=j;
                if(aux>maxim)
                {
                    maxim=aux;
                    anslin=i;
                    anscol=j;
                }
            }
        }
        if(maxim<m)
        {
            maxim=m;
            anslin=0;
            anscol=0;
        }
        cout<<maxim<<"\n";
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=m; j++)
            {
                if(i<=anslin && j<=anscol)
                    cout<<"+";
                else
                    cout<<"-";
            }
            cout<<"\n";
        }
    }
    return 0;
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:78:34: warning: 'anscol' may be used uninitialized in this function [-Wmaybe-uninitialized]
   78 |                 if(i<=anslin && j<=anscol)
      |                                 ~^~~~~~~~
stones.cpp:78:21: warning: 'anslin' may be used uninitialized in this function [-Wmaybe-uninitialized]
   78 |                 if(i<=anslin && j<=anscol)
      |                    ~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 724 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Wrong answer
2 Halted 0 ms 0 KB -