QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#446662#8474. Matrices and SumsluanmengleiAC ✓32ms7052kbC++171.3kb2024-06-17 14:51:452024-06-17 14:51:46

Judging History

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

  • [2024-06-17 14:51:46]
  • 评测
  • 测评结果:AC
  • 用时:32ms
  • 内存:7052kb
  • [2024-06-17 14:51:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

namespace SOL {

using i64 = long long;
void debug(const char *msg, ...) {
#ifdef CLESIP
    va_list arg;
    static char pbString[512];
    va_start(arg,msg);
    vsprintf(pbString,msg,arg);
    cerr << "[DEBUG] " << pbString << "\n";
    va_end(arg);
#endif    
}
template<typename T, typename L>
bool chkmax(T &x, L y) { if (x < y) return x = y, true; return false; }
template<typename T, typename L>
bool chkmin(T &x, L y) { if (y < x) return x = y, true; return false; }

void solve() {
	int n; cin >> n;

	if (n & 1) {
		cout << "No\n";
		return;
	}

	cout << "Yes\n";
	vector<vector<int>> ans(n + 1, vector<int>(n + 1));
	for (int i = 1; i <= n / 2; i ++) {
		int a = n / 2;
		int b = i - 1;
		for (int j = 1; j <= a; j ++)
			ans[i][j] = 1;
		for (int j = 1; j <= b; j ++)
			ans[i][n / 2 + j] = -1;
	}
	for (int i = 1; i <= n / 2; i ++) {
		int a = n / 2 - i + 1;
		int b = n / 2;
		for (int j = 1; j <= a; j ++)
			ans[i + n / 2][j] = 1;
		for (int j = 1; j <= b; j ++)
			ans[i + n / 2][n / 2 + j] = -1;
	}
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= n; j ++)
			cout << ans[i][j] << " \n"[j == n];
}

}
int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	SOL::solve();
	return 0;
}

详细

Test #1:

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

input:

2

output:

Yes
1 0
1 -1

result:

ok OK, Accepted.

Test #2:

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

input:

1

output:

No

result:

ok OK, Accepted.

Test #3:

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

input:

3

output:

No

result:

ok OK, Accepted.

Test #4:

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

input:

4

output:

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

result:

ok OK, Accepted.

Test #5:

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

input:

5

output:

No

result:

ok OK, Accepted.

Test #6:

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

input:

6

output:

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

result:

ok OK, Accepted.

Test #7:

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

input:

7

output:

No

result:

ok OK, Accepted.

Test #8:

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

input:

8

output:

Yes
1 1 1 1 0 0 0 0
1 1 1 1 -1 0 0 0
1 1 1 1 -1 -1 0 0
1 1 1 1 -1 -1 -1 0
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 -1 -1 -1 -1

result:

ok OK, Accepted.

Test #9:

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

input:

9

output:

No

result:

ok OK, Accepted.

Test #10:

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

input:

10

output:

Yes
1 1 1 1 1 0 0 0 0 0
1 1 1 1 1 -1 0 0 0 0
1 1 1 1 1 -1 -1 0 0 0
1 1 1 1 1 -1 -1 -1 0 0
1 1 1 1 1 -1 -1 -1 -1 0
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 -1 -1 -1 -1 -1

result:

ok OK, Accepted.

Test #11:

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

input:

21

output:

No

result:

ok OK, Accepted.

Test #12:

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

input:

37

output:

No

result:

ok OK, Accepted.

Test #13:

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

input:

73

output:

No

result:

ok OK, Accepted.

Test #14:

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

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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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: 3616kb

input:

233

output:

No

result:

ok OK, Accepted.

Test #16:

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

input:

555

output:

No

result:

ok OK, Accepted.

Test #17:

score: 0
Accepted
time: 14ms
memory: 5032kb

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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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: 21ms
memory: 6284kb

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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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: 3552kb

input:

999

output:

No

result:

ok OK, Accepted.

Test #20:

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

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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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.