Submission #333665

# Submission time Handle Problem Language Result Execution time Memory
333665 2020-12-07T12:32:46 Z vipghn2003 Red-blue table (IZhO19_stones) C++14
100 / 100
39 ms 5356 KB
#include<bits/stdc++.h>

using namespace std;

int a[1005][1005];

void solve()
{
    int n,m;
    cin>>n>>m;
    bool swaps=false;
    if(n<m)
    {
        swap(n,m);
        swaps=true;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++) a[i][j]=0;
    }
    int res=0;
    int t=n/2;
    for(int i=1;i<=(m-1)/2;i++)
    {
        for(int j=1;j<=n;j++,t--)
        {
            a[j][res+1]=1;
            if(!t)
            {
                res++;
                t=n/2+1;
            }
        }
    }
    cout<<res+n<<'\n';
    if(swaps) swap(n,m);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            int cur=a[i][j];
            if(swaps) cur=(a[j][i]^1);
            if(cur) cout<<'-';
            else cout<<'+';
        }
        cout<<'\n';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 620 KB Output is correct
4 Correct 2 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 1772 KB Output is correct
2 Correct 34 ms 4716 KB Output is correct
3 Correct 32 ms 4992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 2028 KB Output is correct
2 Correct 31 ms 4076 KB Output is correct
3 Correct 29 ms 3308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 620 KB Output is correct
4 Correct 2 ms 620 KB Output is correct
5 Correct 37 ms 1772 KB Output is correct
6 Correct 34 ms 4716 KB Output is correct
7 Correct 32 ms 4992 KB Output is correct
8 Correct 36 ms 2028 KB Output is correct
9 Correct 31 ms 4076 KB Output is correct
10 Correct 29 ms 3308 KB Output is correct
11 Correct 9 ms 748 KB Output is correct
12 Correct 29 ms 4332 KB Output is correct
13 Correct 33 ms 4844 KB Output is correct
14 Correct 24 ms 3948 KB Output is correct
15 Correct 39 ms 5356 KB Output is correct
16 Correct 28 ms 4736 KB Output is correct
17 Correct 13 ms 3328 KB Output is correct