Submission #993623

# Submission time Handle Problem Language Result Execution time Memory
993623 2024-06-06T08:56:04 Z n3rm1n Red-blue table (IZhO19_stones) C++17
0 / 100
46 ms 5396 KB
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
const int MAXN = 1e3+10;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int n, m;
/// 1 - red
/// 0 - blue
int a[MAXN][MAXN];


void solve_test()
{
    cin >> n >> m;
    if(n >= m)
    {
        memset(a, 1, sizeof(a));
        int togive = (m - 1)/2 ;
        int need = n/2 + 1;
       // cout << togive << " " << need << endl;
        priority_queue < pair < int, int > > q;
        for (int i = 1; i <= m; ++ i)
            q.push(make_pair(0, i));

        for (int i = 1; i <= n; ++ i)
        {

            vector < pair <int, int > > topush;
            for (int j = 0; j < togive; ++ j)
            {
                while(!q.empty() && q.top().first == need)
                {
                    q.pop();
                }
                ///cout << "wtffffff " << q.top().first << endl;
                if(!q.empty())
                {
                    int col = q.top().second;
                    int cnt = q.top().first;
                    q.pop();
                    a[i][col] = 0;
                    topush.push_back({cnt+1, col});
                }
            }
            while(topush.size())
            {
                q.push(topush.back());
                topush.pop_back();
            }
        }
        int cnt = n;
        for (int j = 1; j <= m; ++ j)
        {
            int curr = 0;
            for (int i = 1; i <= n; ++ i)
            {
                if(!a[i][j])curr ++;
            }
            if(curr >= need)cnt ++;
        }
        cout << cnt << endl;
        for (int i = 1; i <= n; ++ i)
        {
            for (int j = 1; j <= m; ++ j)
            {
                if(a[i][j])cout << "+";
                else cout << "-";
            }
            cout << endl;
        }
    }
}
int main()
{
    speed();
    int t;
    cin >> t;
    while(t --)
    {
        solve_test();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4456 KB in the table A+B is not equal to 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 4440 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4456 KB in the table A+B is not equal to 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 4904 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 5396 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4456 KB in the table A+B is not equal to 4
2 Halted 0 ms 0 KB -