답안 #744553

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744553 2023-05-18T18:01:24 Z Andrei Red-blue table (IZhO19_stones) C++17
27 / 100
26 ms 1312 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;
        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:73:34: warning: 'anscol' may be used uninitialized in this function [-Wmaybe-uninitialized]
   73 |                 if(i<=anslin && j<=anscol)
      |                                 ~^~~~~~~~
stones.cpp:73:21: warning: 'anslin' may be used uninitialized in this function [-Wmaybe-uninitialized]
   73 |                 if(i<=anslin && j<=anscol)
      |                    ~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Incorrect 2 ms 340 KB Wrong answer in test 5 29: 31 < 32
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 1312 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 1244 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Incorrect 2 ms 340 KB Wrong answer in test 5 29: 31 < 32
5 Halted 0 ms 0 KB -