Submission #602172

# Submission time Handle Problem Language Result Execution time Memory
602172 2022-07-22T16:16:28 Z Ozy Red-blue table (IZhO19_stones) C++17
38 / 100
28 ms 2048 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 t,fil,col,a,b,res,c,f,x;
char arr[MAX+2][MAX+2];

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

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

        cin >> fil >> col;
        a = 0;
        b = 0;
        if (fil&1) a++;
        else a += 2;
        if (col&1) a++;
        else a += 2;

        b = min(fil,col);
        c = b;
        b = (b-1)/2;
        c -= b;
        res = fil+col;

        if (c <= a) {
            res -= c;
            //solucion de bruta
            if (col > fil) {
                rep(j,1,col) {
                    rep(i,1,fil) {
                        if (i <= b) arr[i][j] = '+';
                        else arr[i][j] = '-';
                    }
                }
            }
            else {
                rep(i,1,fil) {
                    rep(j,1,col) {
                        if (j <= b) arr[i][j] = '-';
                        else arr[i][j] = '+';
                    }
                }
            }

        }
        else {

            res -= a;

            f = fil;
            if (fil&1) f--;
            else f -= 2;

            c = col;
            if (col&1) c--;
            else c -= 2;

            rep(i,1,f) {
                rep(j,1,c) {
                    x = i+j;
                    if (x&1) arr[i][j] = '+';
                    else arr[i][j] = '-';
                }
            }

            rep(i,1,f) {
                rep(j,c+1,col) arr[i][j] = '+';
            }

            rep(j,1,c) {
                rep(i,f+1,fil) arr[i][j] = '-';
            }

            rep(i,f+1,fil) {
                rep(j,c+1,col) arr[i][j] = '+';
            }

        }

        cout << res << "\n";
        rep(i,1,fil) {
            rep(j,1,col) cout << arr[i][j];
            cout << "\n";
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Incorrect 2 ms 340 KB Wrong answer in test 38 5: 40 < 41
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1380 KB Output is correct
2 Correct 18 ms 1876 KB Output is correct
3 Correct 25 ms 2048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 1440 KB Wrong answer in test 6 6: 8 < 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Incorrect 2 ms 340 KB Wrong answer in test 38 5: 40 < 41
5 Halted 0 ms 0 KB -