Submission #993333

# Submission time Handle Problem Language Result Execution time Memory
993333 2024-06-05T13:49:27 Z simona1230 Red-blue table (IZhO19_stones) C++17
100 / 100
38 ms 2392 KB
#include <bits/stdc++.h>

using namespace std;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
char c[1024][1024];
int cnt[1024];
void read()
{
    memset(cnt,0,sizeof(cnt));
    int n,m;
    cin>>n>>m;
    bool s=0;
    if(m<n)s=1,swap(n,m);

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            c[i][j]='-';
        }
    }

    int j=1;
    int ans=m;
    for(int i=1;i<=n;i++)
    {
        int curr=m/2+1;
        while(curr)
        {
            if(cnt[j]==n-n/2-1)break;
            cnt[j]++;
            c[i][j]='+';
            curr--;

            j++;
            if(j==m+1)j=1;
        }

        if(curr)break;
        ans++;
    }

    cout<<ans<<endl;
    if(s)
    {
        for(int j=1; j<=m; j++)
        {
            for(int i=1; i<=n; i++)
            {
                if(c[i][j]=='-')cout<<"+";
                else cout<<"-";
            }
            cout<<endl;
        }
    }
    else
    {
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=m; j++)
            {
                cout<<c[i][j];
            }
            cout<<endl;
        }
    }
}

int main()
{
    speed();
    int t;
    cin>>t;
    while(t--)
        read();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 11 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 1456 KB Output is correct
2 Correct 18 ms 2004 KB Output is correct
3 Correct 19 ms 2052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1360 KB Output is correct
2 Correct 17 ms 1884 KB Output is correct
3 Correct 16 ms 1624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 11 ms 348 KB Output is correct
5 Correct 38 ms 1456 KB Output is correct
6 Correct 18 ms 2004 KB Output is correct
7 Correct 19 ms 2052 KB Output is correct
8 Correct 29 ms 1360 KB Output is correct
9 Correct 17 ms 1884 KB Output is correct
10 Correct 16 ms 1624 KB Output is correct
11 Correct 18 ms 600 KB Output is correct
12 Correct 17 ms 1628 KB Output is correct
13 Correct 19 ms 1636 KB Output is correct
14 Correct 14 ms 1372 KB Output is correct
15 Correct 21 ms 2392 KB Output is correct
16 Correct 14 ms 1892 KB Output is correct
17 Correct 7 ms 1116 KB Output is correct