Submission #333614

# Submission time Handle Problem Language Result Execution time Memory
333614 2020-12-07T08:28:00 Z vipghn2003 Red-blue table (IZhO19_stones) C++14
0 / 100
425 ms 3436 KB
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
using namespace std;

const int N=1005;
char ans1[N][N],ans2[N][N];

void solve()
{
    int n,m;
    cin>>n>>m;
    int res1=n;
    set<pii>cur;
    for(int j=1;j<=m;j++) cur.insert(mp(0,j));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++) ans1[i][j]='+';
        int can=(m-1)/2;
        while(!cur.empty()&&can)
        {
            can--;
            auto x=*cur.rbegin();
            cur.erase(x);
            int col=x.se;
            ans1[i][col]='-';
            if(x.fi+1>(m-x.fi-1))
            {
                res1++;
            }
            else cur.insert(mp(x.fi+1,x.se));
        }
    }
    cur.clear();
    int res2=m;
    for(int i=1;i<=n;i++) cur.insert(mp(0,i));
    for(int j=1;j<=m;j++)
    {
        for(int i=1;i<=n;i++) ans2[i][j]='-';
        int can=(n-1)/2;
        while(!cur.empty()&&can)
        {
            can--;
            auto x=*cur.rbegin();
            cur.erase(x);
            int row=x.se;
            ans2[row][j]='+';
            if(x.fi+1>(n-x.fi-1))
            {
                res2++;
            }
            else cur.insert(mp(x.fi+1,x.se));
        }
    }
    if(res1<res2)
    {
        swap(res1,res2);
        swap(ans1,ans2);
    }
    cout<<res1<<'\n';
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++) cout<<ans1[i][j];
        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 4 ms 2284 KB Output is correct
2 Incorrect 10 ms 2284 KB in the table A+B is not equal to 6
# Verdict Execution time Memory Grader output
1 Incorrect 241 ms 2412 KB in the table A+B is not equal to 48
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2284 KB Output is correct
2 Incorrect 10 ms 2284 KB in the table A+B is not equal to 6
# Verdict Execution time Memory Grader output
1 Incorrect 425 ms 3436 KB in the table A+B is not equal to 118
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 103 ms 1644 KB in the table A+B is not equal to 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2284 KB Output is correct
2 Incorrect 10 ms 2284 KB in the table A+B is not equal to 6