测试例子过了,手动例子也全过了,为什么9个WA,1个TLE
查看原帖
测试例子过了,手动例子也全过了,为什么9个WA,1个TLE
952053
MarsVenus楼主2023/3/11 19:57
#define _CRT_SECURE_NO_WARNINGS
#include<vector>
#include<iostream>
#include<cstdio>
#include<string.h>
#include<string>
#include<climits>
#include<cmath>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
using namespace std;

int main(void)
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> v(n+1, vector<int>(n+1));
	int i, j,k,p;
	int t = 1;
	for (i = 1;i <= n;i++)
		for (j = 1;j <= n;j++)
			v[i][j] = t++;
		
	int x, y, r, z;
	while (m--) {
		int tt;
		cin >> x >> y >> r >> z;
		for (k = x - r;k <= x + r;k++)
			for (p = x-r;p <k;p++) {
				swap(v[k][p], v[p][k]);
			}
		if (z) {
			for (k = x - r;k < x;k++)
				for (p = y - r;p <=y+r;p++)
					swap(v[k][p], v[x+r-(k-(x-r))][p]);
		}
		else {
			for (k = x - r;k <= x+r;k++)
				for (p = y - r;p <y;p++)
					swap(v[k][p], v[k][y + r-(p-(y-r))]);
		}
	}
	
	for (i = 1;i <=n;i++) {
		for (j = 1;j <=n;j++)
			cout << v[i][j] << " ";
		cout << endl;
	}
	return 0;
}
2023/3/11 19:57
加载中...