求调代码
查看原帖
求调代码
764102
Zpril楼主2023/9/19 21:14

输出部分格式错误,调了半个小时。

#include <bits/stdc++.h> // 
#define FastIO ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint const int
#define rint register int
// #define int long long
using namespace std;
using namespace std::literals;
using namespace std::string_literals;
using namespace std::chrono;
typedef long long ll;
typedef size_t ull;

int a[1005][1005], b[1005][1005], n, m;

signed main() {
    FastIO;
    // freopen(".out", "w", stdout);
	int cnt = 1;
    cin >> n >> m;

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            a[i][j] = cnt++;
        }
    }

    memcpy(b, a, sizeof a);

    while (m--) {
        int x, y, r, z;
        cin >> x >> y >> r >> z;
        if (z == 0) {
            for (int i = -r; i <= r; i++){
                for (int j = -r; j <= r; j++){
                    b[x + j][y - i] = a[x + i][y + j];
                }
            }
        } else {
            for (int i = -r; i <= r; i++){
                for (int j = -r; j <= r; j++){
                    b[x - j][y + i] = a[x + i][y + j];
                }
            }
        }
        memcpy(a, b, sizeof b);
    }
 
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cout << a[i][j] << " ";
            //cout << "awa";
        }
        puts("");
    }

    return 0;
}
2023/9/19 21:14
加载中...