Submission #163143

# Submission time Handle Problem Language Result Execution time Memory
163143 2019-11-11T13:59:06 Z abacaba Red-blue table (IZhO19_stones) C++14
27 / 100
35 ms 2004 KB
#include <iostream>
#include <string>
#include <unordered_map>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define y1 abcde
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

const int inf = 2e9;
const int N = 1e3 + 15;
int t, n, m, a[N][N], row[N], col[N];

inline void make_red(int i, int j) {
    a[i][j] = 1, ++row[i], ++col[j];
}

inline void make_blue(int i, int j) {
    a[i][j] = 0, --row[i], --col[j];
}

main() {
    ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
    cin >> t;
    while(t--) {
        int ans = 0;
        for(int i = 1; i <= n; ++i)
            for(int j = 1; j <= m; ++j)
                a[i][j] = row[i] = col[j] = 0;
        cin >> n >> m;
        if(n >= m) {
            for(int i = 1; i <= n; ++i)
                for(int j = 1; j <= m / 2 + 1; ++j)
                    make_red(i, j);
        }
        else {
            for(int i = 1; i <= n; ++i)
                for(int j = 1; j <= m; ++j)
                    make_red(i, j);
            for(int i = 1; i <= n / 2 + 1; ++i)
                for(int j = 1; j <= m; ++j)
                    make_blue(i, j);
        }
        for(int i = 1; i <= n; ++i)
            ans += 2 * row[i] > m;
        for(int i = 1; i <= m; ++i)
            ans += 2 * col[i] < n;
        cout << ans << endl;
        for(int i = 1; i <= n; ++i, cout << endl)
            for(int j = 1; j <= m; ++j)
                cout << (a[i][j] ? '+' : '-');
    }
    return 0;
}

Compilation message

stones.cpp:53:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Incorrect 4 ms 632 KB Wrong answer in test 5 29: 31 < 32
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 1784 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 2004 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 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Incorrect 4 ms 632 KB Wrong answer in test 5 29: 31 < 32