Submission #1092470

# Submission time Handle Problem Language Result Execution time Memory
1092470 2024-09-24T07:27:26 Z juicy Red-blue table (IZhO19_stones) C++17
0 / 100
35 ms 1424 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  int t; cin >> t;
  while (t--) {
    int n, m; cin >> n >> m;
    array<int, 2> res{m, 0};
    vector<int> cnt(m), ord(m); iota(ord.begin(), ord.end(), 0);
    int cur = m, cut = n / 2;
    auto cmp = [&](int a, int b) -> bool {
        if (cnt[a] >= cut && cnt[b] >= cut) {
          return a < b;
        }
        if (cnt[a] >= cut) {
          return 1;
        } 
        if (cnt[b] >= cut) {
          return 0;
        }
        return cnt[a] < cnt[b];
    };
    for (int i = 0; i < n; ++i) {
      sort(ord.begin(), ord.end(), cmp);
      for (int j = 0, k = 0; j < m / 2 + 1; ++j) {
        while (cnt[ord[k]] == n) {
          ++k;
        }
        cur -= ++cnt[ord[k++]] == cut;
      }
      res = max(res, {cur + i + 1, i + 1});
    }
    fill(cnt.begin(), cnt.end(), 0);
    vector a(n, vector<char>(m, '-'));
    for (int i = 0; i < res[1]; ++i) {
      sort(ord.begin(), ord.end(), cmp);
      for (int j = 0, k = 0; j < m / 2 + 1; ++j) {
        while (cnt[ord[k]] == n) {
          ++k;
        }
        ++cnt[ord[k]];
        a[i][ord[k++]] = '+';
      }
    }
    cout << res[0] << "\n";
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        cout << a[i][j];
      }
      cout << "\n";
    }
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 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 1 ms 348 KB Wrong answer in test 3 45: 45 < 46
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 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 35 ms 1364 KB Wrong answer in test 97 21: 110 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 1424 KB Wrong answer in test 19 19: 34 < 36
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB in the table A+B is not equal to 4
2 Halted 0 ms 0 KB -