답안 #602347

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
602347 2022-07-22T23:13:53 Z Ozy Red-blue table (IZhO19_stones) C++17
26 / 100
21 ms 2084 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "

#define MAX 1000

lli n,m,t,mejor,lim,f,c,b,a,ini,todo;
pair<lli,lli> cant;
char res[MAX+2][MAX+2];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> t;
    rep(i,1,t) {

        cin >> n >> m;
        mejor = 0;
        f = n / 2;
        f++;
        c = m / 2;
        c++;
        lim = n*m;

        repa(i,n,0) {
            repa(j,m,0) {
                a = i*c;
                a += j*f;
                b = i + j;

                if (a > lim) continue;
                if (b <= mejor) break;

                mejor = b;
                cant = {i,j};
            }
        }

        rep(i,1,n) {
            rep(j,1,m) res[i][j] = '-';
        }

        ini = 1;
        c -= m - cant.second;

        rep(i,1,cant.first) {
            rep(j,1,c) {
                res[i][ini] = '+';
                ini++;
                if (ini > cant.second) ini = 1;
            }
            rep(j,cant.second+1,m) res[i][j] = '+';
        }

        cout << mejor << "\n";
        rep(i,1,n) {
            rep(j,1,m) cout << res[i][j];
            cout << "\n";
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB in the table A+B is not equal to 5
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB in the table A+B is not equal to 7
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB in the table A+B is not equal to 5
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 1488 KB Output is correct
2 Correct 19 ms 1896 KB Output is correct
3 Correct 19 ms 2084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 1424 KB Output is correct
2 Correct 19 ms 1828 KB Output is correct
3 Correct 17 ms 1564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB in the table A+B is not equal to 5
3 Halted 0 ms 0 KB -