QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#581344#4633. Coprime Matriceschuchu#WA 0ms3608kbC++141.2kb2024-09-22 12:11:352024-09-22 12:11:36

Judging History

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

  • [2024-09-22 12:11:36]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3608kb
  • [2024-09-22 12:11:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define FINISH cerr << "FINISH" << endl;
#define debug(x) cerr << #x << " == " << x << endl
#define el '\n'
#define fir first
#define sec second
typedef long long ll;
typedef pair<int, int> PII;
const int mod = 1000000007;
const int inf = 0x3f3f3f3f;
const int N = 200020;
int up(int x, int m)
{
	int r = (x % m + m) % m;
	if (r == 0)
		r = m;
	return r;
}
void solve()
{
	int n, m, x, y, w;
	cin >> n >> m >> x >> y >> w;
	vector<vector<int>> a(n + 1, vector<int>(m + 1, 0));
	a[x][y] = w;
	int tmp = 0;
	for (int i = 1; i <= m; i += 2) {
		if (i == m) {
			for (int j = 1; j <= n; j++) {
				a[j][i] = ++tmp;
			}
		}
		else {
			for (int j = 1; j <= n; j++) {
				if (j % 2 == 1) {
					a[j][i] = ++tmp;
					a[j][i + 1] = ++tmp;
				}
				else {
					a[j][i + 1] = ++tmp;
					a[j][i] = ++tmp;
				}
			}
		}
	}
	int res = w - a[x][y];
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			a[i][j] = up(a[i][j] + res, n * m);
			cout << a[i][j] << " ";
		}
		cout << el;
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3 2 1 3

output:

9 1 6 
3 2 7 
4 5 8 

result:

wrong answer First Line not Yes