QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#291380#4633. Coprime MatricesyyzWA 0ms3524kbC++142.3kb2023-12-26 14:21:012023-12-26 14:21:01

Judging History

你现在查看的是最新测评结果

  • [2023-12-26 14:21:01]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3524kb
  • [2023-12-26 14:21:01]
  • 提交

answer

#include <bits/stdc++.h>
#define V vector
#define Vi vector<int>
#define sz(a) ((int)a.size())
#define fi first
#define se second
#define Int pair<int, int>
#define Inf ((int)1e9)
#define pb push_back
#define ins insert
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define seg int p, int l, int r
#define lid p << 1, l, mid
#define all(a) a.begin(), a.end()
#define rid p << 1 | 1, mid + 1, r
#define mid ((l + r) / 2)
#define Ceil(x, y) (((x) + (y)-1) / (y))
#define cmax(a, b) a = max(a, b)
#define cmin(a, b) a = min(a, b)
#define IO(x) freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout);
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
  IO(1);
#endif
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  int n, m, x, y, z;
  cin >> n >> m >> x >> y >> z;

  V<Vi> res(n + 5, Vi(m + 5));
  res[x][y] = z;
  V<Vi> s(2);
  For(i, 1, n * m) if (i != z) s[i & 1].pb(i);

  int s0 = (n * n + 1) / 2, s1 = n * n - s0;
  if (s0 == s1 || ((x + y) & 1) != (z & 1)) {
    int t = ((x + y) & 1), Z = (z & 1);
    Vi p(2);
    p[t] = Z, p[t ^ 1] = Z ^ 1;
    For(i, 1, n) For(j, 1, m) if (!res[i][j]) {
      res[i][j] = s[p[(i + j) & 1]].back();
      s[p[(i + j) & 1]].pop_back();
    }
    cout << "Yes\n";
    For(i, 1, n) {
      For(j, 1, m) cout << res[i][j] << ' ';
      cout << '\n';
    }
    return 0;
  }
  if (z != 1) {
    if (x == 1 && y == 1) {
      if (n > 1)
        res[n][1] = 1;
      else
        res[1][m] = 1;
    } else
      res[1][1] = 1;
    For(i, 1, n) For(j, 1, m) if (!res[i][j]) {
      res[i][j] = s[(i + j) & 1].back();
      s[(i + j) & 1].pop_back();
    }
    cout << "Yes\n";
    For(i, 1, n) {
      For(j, 1, m) cout << res[i][j] << ' ';
      cout << '\n';
    }
    return 0;
  }
  if (!res[1][1]) {
    res[1][1] = s[1].back();
    s[1].pop_back();
  }
  if (!res[1][2]) {
    res[1][2] = s[1].back();
    s[1].pop_back();
  }
  if (!res[2][1]) {
    res[2][1] = s[1].back();
    s[1].pop_back();
  }
  For(i, 1, n) For(j, 1, m) if (!res[i][j]) {
    res[i][j] = s[(i + j) & 1].back();
    s[(i + j) & 1].pop_back();
  }
  cout << "Yes\n";
  For(i, 1, n) {
    For(j, 1, m) cout << res[i][j] << ' ';
    cout << '\n';
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3524kb

input:

3 3 2 1 3

output:

Yes
1 9 8 
3 6 7 
4 5 2 

result:

wrong output format Expected EOLN