답안 #173495

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
173495 2020-01-04T09:35:20 Z vex Red-blue table (IZhO19_stones) C++14
0 / 100
32 ms 1308 KB
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define poc first
#define kraj second
#define maxn 1055005
using namespace std;

int n,m;
int treba_red;
int treba_kol;
bool moze(int red,int kol)
{
    int sad_red = treba_red - (m - kol);
    int sad_kol = treba_kol - (n - red);
    int sad_n = red;
    int sad_m = kol;

    if(sad_red < 0 || sad_kol < 0)return true;

    int uk_red = sad_red * sad_n;
    int manji_kol = uk_red / sad_m;
    int veci_kol = manji_kol + 1;
    int br_veci = uk_red % sad_m;

    if(br_veci > 0)
    {
        return sad_n - veci_kol >= sad_kol;
    }
    return sad_n - manji_kol >= sad_kol;
}
int br[1005];
void ispisi(int red,int kol)
{
    cout<<red + kol<<"\n";
    for(int i=1;i<=m;i++)br[i] = 0;
    int sad_red = treba_red - (m - kol);
    for(int i=1;i<=n;i++)
    {
        int treba = sad_red;
        int minn = 10005;
        for(int j=1;j<=m;j++)
        {
            minn = min(br[j],minn);
        }
        for(int j=1;j<=m;j++)
        {
            if(j > kol)
            {
                cout<<"+";
            }
            else if(i > red)
            {
                cout<<"-";
            }
            else
            {
                if(sad_red <= 0)
                {
                    cout<<"-";
                }
                else
                {
                    if(br[j] == minn || (kol - j + 1) == treba)
                    {
                        treba--;
                        cout<<"+";
                        br[j]++;
                    }
                    else
                    {
                        cout<<"-";
                    }
                }
            }
        }
        cout<<"\n";
    }
}

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

    int t;
    cin>>t;
    while(t > 0)
    {
        t--;
        cin>>n>>m;

        treba_red = (m+2)/2;
        treba_kol = (n+2)/2;

        int maxx = 0;
        int maxx_red = 0;
        int maxx_kol = 0;
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=m;j++)
            {
                if(i + j > maxx && moze(i,j))
                {
                    maxx = i + j;
                    maxx_red = i;
                    maxx_kol = j;
                }
            }
        }

        ispisi(maxx_red,maxx_kol);
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Runtime error 3 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Runtime error 3 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 632 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 32 ms 1308 KB in the table A+B is not equal to 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Runtime error 3 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)