Submission #145875

# Submission time Handle Problem Language Result Execution time Memory
145875 2019-08-21T09:40:29 Z davitmarg Red-blue table (IZhO19_stones) C++17
0 / 100
90 ms 1476 KB
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <iomanip>
#include <stack>
#include <cassert>
#include <iterator>
#include <bitset>
#include <fstream>
#define mod 998244353ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;
 
int t,n,m,ans;
char a[1003][1003];
int main()
{
    cin>>t;
    while(t--)
    {
        cin>>n>>m;
        priority_queue<pair<int,int>> q;
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
                a[i][j]='+';
 
        for(int i=1;i<=n;i++)
            q.push(MP(0,i));
 
        for(int j=1;j<=m;j++)
        {
            vector<pair<int,int>> d; 
            for(int i=1;i<=n/2+1;i++)
            {
                pair<int,int> p=q.top();
                q.pop();
                p.first++;
                if(p.first==m-m/2-1)
                    p.first=-mod;
                d.PB(p);
                a[p.second][j]='-';
            }
            while(!d.empty())
            {
                q.push(d.back());
                d.pop_back();
            }
        }
        ans=m;
        for(int i=1;i<=n;i++)
        {
            int sum=0;
            for(int j=1;j<=m;j++)
                sum+=(a[i][j]=='+');
            ans+=(sum>=m/2+1);
        }
        printf("%d\n",ans);
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
                printf("%c",a[i][j]);
            printf("\n");
        }
 
    }
    
    
	return 0;
}
 
/*

2
1 3
3 3

 
*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB Wrong answer in test 2 1: 1 < 2
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Wrong answer in test 2 1: 1 < 2
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB Wrong answer in test 2 1: 1 < 2
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 1476 KB Wrong answer in test 97 21: 69 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 1396 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB Wrong answer in test 2 1: 1 < 2