Submission #556040

# Submission time Handle Problem Language Result Execution time Memory
556040 2022-05-02T08:40:46 Z HeatDroppa Red-blue table (IZhO19_stones) C++14
100 / 100
9 ms 2260 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int tst,n,m;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>tst;
    while(tst--)
    {
        cin>>n>>m;
        pii ans(n,0);
        if(m>n) ans=pii(0,m);
        for(int i=n;i>=1;--i)
        for(int j=m;j>=1;--j)
        {
            if(i+j<=ans.first+ans.second)
                break;
            int x=n/2+1,y=m/2+1;
            x=max(0,x-n+i);
            if(x==0)
            {
                ans=pii(i,j);
                continue;
            }
            if(m==y)
                continue;
            int tmp=0,rem=0;
            for(int _i=0;_i<x&&tmp<=i;++_i)
            for(int _j=0;_j<j&&tmp<=i;++_j)
            {
                if(rem==0) ++tmp,
                    rem=min(j,m-y);
                --rem;
            }
            if(tmp<=i) ans=pii(i,j);
        }
        cout<<ans.first+ans.second<< '\n';
        int x=n/2+1,y=m/2+1;
        x=max(0,x-n+ans.first);
        vector<string> s(ans.first,string(m,'+'));
        int tmp=-1,rem=0;
        for(int i = 0; i < x; ++i)
        for(int j=m-ans.second;j<m;++j)
        {
            if(rem==0) ++tmp,
                rem=min(ans.second,m-y);
            s[tmp][j]='-'; --rem;
        }
        for(auto i:s) cout<<i<<'\n';
        for(int i=ans.first;i<n;++i)
            cout<<string(m,'-')<<'\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 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 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1364 KB Output is correct
2 Correct 6 ms 1620 KB Output is correct
3 Correct 5 ms 1996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1348 KB Output is correct
2 Correct 5 ms 1364 KB Output is correct
3 Correct 4 ms 1200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 Correct 2 ms 340 KB Output is correct
5 Correct 8 ms 1364 KB Output is correct
6 Correct 6 ms 1620 KB Output is correct
7 Correct 5 ms 1996 KB Output is correct
8 Correct 8 ms 1348 KB Output is correct
9 Correct 5 ms 1364 KB Output is correct
10 Correct 4 ms 1200 KB Output is correct
11 Correct 4 ms 468 KB Output is correct
12 Correct 4 ms 1560 KB Output is correct
13 Correct 5 ms 1232 KB Output is correct
14 Correct 4 ms 1020 KB Output is correct
15 Correct 9 ms 2260 KB Output is correct
16 Correct 9 ms 1728 KB Output is correct
17 Correct 3 ms 980 KB Output is correct