56分求助
查看原帖
56分求助
790268
fgcjd楼主2024/3/3 15:39

过了1、3、5、6

求助!

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <limits>
#include <iomanip>
#include <string>
using namespace std;
typedef long long ll;
int k, sx, sy;
void w(int x, int y, int t){
	cout << y << " " << x << " " << t << endl;
}
void in(int x, int y, int s, int a, int b){
	if (s <= 1) return ;
	int s2 = s;
	s = s / 2;
	if (x <= a && a < x + s && y <= b && b < y + s){
		w(x + s, y + s, 1);
		in(x, y, s, a, b);
		in(x + s, y, s, x + s, y + s - 1);
		in(x, y + s, s, x + s - 1, y + s);
		in(x + s, y + s, s, x + s, y + s);
	}
	else if (x + s <= a && a < x + s2 && y <= b && b < y + s){
		w(x + s - 1, y + s, 2);
		in(x, y, s, x + s - 1, y + s - 1);
		in(x + s, y, s, a, b);
		in(x, y + s, s, x + s - 1, y + s);
		in(x + s, y + s, s, x + s, y + s);
	}
	else if (x <= a && a < x + s && y + s <= b && b < y + s2){
		w(x + s, y + s - 1, 3);
		in(x, y, s, x + s - 1, y + s - 1);
		in(x + s, y, s, x + s, y + s - 1);
		in(x, y + s, s, a, b);
		in(x + s, y + s, s, x + s, y + s);
	}
	else if (x + s <= a && a < x + s2 && y + s <= b && b < y + s2){
		w(x + s - 1, y + s - 1, 4);
		in(x, y, s, x + s - 1, y + s - 1);
		in(x + s, y, s, x + s, y + s - 1);
		in(x, y + s, s, x + s - 1, y + s);
		in(x + s, y + s, s, a, b);
	}
}
int main(){
	cin >> k >> sx >> sy;
	in(1, 1, pow(2, k), sx, sy);
	return 0;
}
2024/3/3 15:39
加载中...