QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#557863#8474. Matrices and SumsXiaohubaAC ✓55ms7584kbC++232.9kb2024-09-11 11:41:362024-09-11 11:41:43

Judging History

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

  • [2024-09-11 11:41:43]
  • 评测
  • 测评结果:AC
  • 用时:55ms
  • 内存:7584kb
  • [2024-09-11 11:41:36]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

// #define LOCK_GETCHAR
// #define USE_INT_128

#if __cplusplus < 201400
#warning "Please use c++14 or higher."
#define CONSTEXPR_FUNC
#define ENABLE_IF_INT
#else
#define CONSTEXPR_FUNC constexpr
#define ENABLE_IF_INT , enable_if_t<_is_integer<T>, int> = 0
template <class T> constexpr bool _is_integer = numeric_limits<T>::is_integer;
template <> constexpr bool _is_integer<bool> = false;
template <> constexpr bool _is_integer<char> = false;
#ifdef USE_INT_128
template <> constexpr bool _is_integer<__int128> = true;
template <> constexpr bool _is_integer<__uint128_t> = true;
#endif
#endif

#if !defined(_WIN32) && !defined(LOCK_GETCHAR)
#define getchar getchar_unlocked
#endif

#define il inline
#define mkp make_pair
#define fi first
#define se second
#define _loop_i_t(j, k) make_signed_t<decltype((j) - (k))>
#define For(i, j, k) for (_loop_i_t(j, k) i = (j); i <= (k); ++i) // NOLINT
#define ForDown(i, j, k)                                                       \
  for (_loop_i_t(j, k) i = (j); i >= decltype(i)(k); --i) // NOLINT
#define eb emplace_back
#ifndef ONLINE_JUDGE
#define FileIO(filename)                                                       \
  freopen(filename ".in", "r", stdin);                                         \
  freopen(filename ".out", "w", stdout)
#else
#define FileIO(filename) void(0)
#endif

using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
using db = double;
using ldb = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#ifdef USE_INT_128
using lll = __int128_t;
using ulll = __uint128_t;
#endif

// clang-format off
CONSTEXPR_FUNC il ll qpow(ll x, ull y, ll mod){ ll ans = 1; x %= mod; while (y) { if (y & 1) (ans *= x) %= mod; (x *= x) %= mod; y >>= 1; } return ans; }
template<typename T> CONSTEXPR_FUNC il void cmin(T & x, const T &y){ x = min(x, y); }
template<typename T> CONSTEXPR_FUNC il void cmax(T & x, const T &y){ x = max(x, y); }
template<typename T ENABLE_IF_INT> il void read(T &x){ x = 0; int f = 1; int c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); } x *= f; }
template<typename T, typename ... Args> il void read(T &x, Args &... y){ read(x), read(y...); }
// clang-format on

// File head end

namespace {
// constexpr ll MAXN = ...;
int n, a[1005][1005];
il void Main() {
  read(n);
  if (n & 1)
    puts("No");
  else {
    puts("Yes");
    For(i, 1, n / 2) For(j, 1, n / 2) a[i][j] = -1;
    For(i, n / 2 + 1, n) For(j, n / 2 + 1, n) a[i][j] = 1;
    For(i, 1, n / 2) For(j, n / 2 + 1, n - i + 1) a[i][j] = -1;
    For(i, n / 2 + 1, n) For(j, n / 2 - (i - (n / 2) - 1) + 1, n / 2) a[i][j] =
        1;
    For(i, 1, n) For(j, 1, n) cout << a[i][j] << " \n"[j == n];
  }
}
} // namespace

signed main() { return Main(), 0; }

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3668kb

input:

2

output:

Yes
-1 -1
0 1

result:

ok OK, Accepted.

Test #2:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

1

output:

No

result:

ok OK, Accepted.

Test #3:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

3

output:

No

result:

ok OK, Accepted.

Test #4:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

4

output:

Yes
-1 -1 -1 -1
-1 -1 -1 0
0 0 1 1
0 1 1 1

result:

ok OK, Accepted.

Test #5:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

5

output:

No

result:

ok OK, Accepted.

Test #6:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

6

output:

Yes
-1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 0
-1 -1 -1 -1 0 0
0 0 0 1 1 1
0 0 1 1 1 1
0 1 1 1 1 1

result:

ok OK, Accepted.

Test #7:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

7

output:

No

result:

ok OK, Accepted.

Test #8:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

8

output:

Yes
-1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 0
-1 -1 -1 -1 -1 -1 0 0
-1 -1 -1 -1 -1 0 0 0
0 0 0 0 1 1 1 1
0 0 0 1 1 1 1 1
0 0 1 1 1 1 1 1
0 1 1 1 1 1 1 1

result:

ok OK, Accepted.

Test #9:

score: 0
Accepted
time: 0ms
memory: 3728kb

input:

9

output:

No

result:

ok OK, Accepted.

Test #10:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

10

output:

Yes
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 0
-1 -1 -1 -1 -1 -1 -1 -1 0 0
-1 -1 -1 -1 -1 -1 -1 0 0 0
-1 -1 -1 -1 -1 -1 0 0 0 0
0 0 0 0 0 1 1 1 1 1
0 0 0 0 1 1 1 1 1 1
0 0 0 1 1 1 1 1 1 1
0 0 1 1 1 1 1 1 1 1
0 1 1 1 1 1 1 1 1 1

result:

ok OK, Accepted.

Test #11:

score: 0
Accepted
time: 0ms
memory: 3496kb

input:

21

output:

No

result:

ok OK, Accepted.

Test #12:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

37

output:

No

result:

ok OK, Accepted.

Test #13:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

73

output:

No

result:

ok OK, Accepted.

Test #14:

score: 0
Accepted
time: 1ms
memory: 4120kb

input:

100

output:

Yes
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

result:

ok OK, Accepted.

Test #15:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

233

output:

No

result:

ok OK, Accepted.

Test #16:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

555

output:

No

result:

ok OK, Accepted.

Test #17:

score: 0
Accepted
time: 16ms
memory: 6652kb

input:

666

output:

Yes
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

result:

ok OK, Accepted.

Test #18:

score: 0
Accepted
time: 55ms
memory: 7040kb

input:

888

output:

Yes
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

result:

ok OK, Accepted.

Test #19:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

999

output:

No

result:

ok OK, Accepted.

Test #20:

score: 0
Accepted
time: 32ms
memory: 7584kb

input:

1000

output:

Yes
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

result:

ok OK, Accepted.