QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#223492#6743. water235luanmenglei#WA 0ms3844kbC++171.6kb2023-10-22 10:25:062023-10-22 10:25:06

Judging History

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

  • [2023-10-22 10:25:06]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3844kb
  • [2023-10-22 10:25:06]
  • 提交

answer

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

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    
}

#define PASSED debug("PASSED (%s) LINE #%s", __FUNCTION__, __LINE__)

using i64 = long long;
using i128 = __int128_t;
template <typename T, typename L> void chkmax(T &x, L y) { if (x < y) x = y; }
template <typename T, typename L> void chkmin(T &x, L y) { if (x > y) x = y; }

void solve() {
	int n, m; cin >> n >> m;
	vector<vector<int>> ans(n + 1, vector<int>(m + 1));

	int cnt = 0;
	if (n == 1) {
		for (int i = 1; i <= m; i += 2) {
			++ cnt;
			ans[1][i] = 1;
		}
		if (m % 2 == 0)
			ans[1][m] = 1, ++ cnt;
	} else if (m == 1) {
		for (int i = 1; i <= n; i += 2) {
			++ cnt;
			ans[i][1] = 1;
		}
		if (n % 2 == 0)
			ans[n][1] = 1, ++ cnt;
	} else {
		if (n > m) {
			int k = 1, j = 1;
			for (int i = 1; i <= n; i ++) {
				ans[i][j] = 1;
				++ cnt;

				if (j == 1 && k == -1)
					k = 1;
				if (j == m && k == 1)
					k = -1;
				j += k;
			}
		} else {
			int k = 1, j = 1;
			for (int i = 1; i <= m; i ++) {
				ans[j][i] = 1;
				++ cnt;

				if (j == 1 && k == -1)
					k = 1;
				if (j == n && k == 1)
					k = -1;
				j += k;
			}
		}
	}
	
	cout << cnt << "\n";
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= m; j ++)
			cout << ans[i][j] << " \n"[j == m];
}

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

详细

Test #1:

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

input:

2 1

output:

2
1
1

result:

ok The answer is correct.

Test #2:

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

input:

3 3

output:

3
1 0 0
0 1 0
0 0 1

result:

ok The answer is correct.

Test #3:

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

input:

1 4

output:

3
1 0 1 1

result:

ok The answer is correct.

Test #4:

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

input:

2 2

output:

2
1 0
0 1

result:

ok The answer is correct.

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3612kb

input:

2 4

output:

4
1 0 1 0
0 1 0 1

result:

wrong answer The answer is wrong: expected = 3, found = 4