QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#181474#7226. The Impressive Pathucup-team288TL 1ms3516kbC++201.9kb2023-09-16 19:27:072023-09-16 19:27:07

Judging History

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

  • [2023-09-16 19:27:07]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:3516kb
  • [2023-09-16 19:27:07]
  • 提交

answer

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using i64 = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l)==r], ++l; }
#else
#define DE(...) 0
#define debug(...) 0
#endif

vector<int> dx{1, 2, 2, 1, -1, -2, -2, -1};
vector<int> dy{2, 1, -1, -2, -2, -1, 1, 2}; 

int main() {
	cin.tie(nullptr)->sync_with_stdio(false);

	int n, m, t;
	cin >> n >> m >> t;

	auto prune = [&](int turn, int x, int y) {
		int X = n - 1 - x, Y = m - 1 - y;
		if (max(X, Y) > 2 * turn) {
			return true;
		}
		if (X + Y > 3 * turn) {
			return true;
		}
		return false;
	};

	vector vis(n, vector<int>(m));
	vis[0][0] = true;
	vector<pair<int, int>> ans;

	auto rec = [&](auto rec, int cur, int x, int y) -> void {
		//cerr << cur << ' ' << x << ' ' << y << '\n';
		if (cur == t && x == n - 1 && y == m - 1) {
			for (int i = 0; i < t; i++) {
				cout << ans[i].first + 1 << ' ' << ans[i].second + 1 << '\n';
			}
			exit(0);
		}
		if (cur == t) {
			return;
		}
		for (int dir = 0; dir < 8; dir++) {
			int nx = x + dx[dir], ny = y + dy[dir];
			if (cur != t - 1 && nx == n - 1 && ny == m - 1) {
				continue;
			}
			if (0 <= nx && nx < n && 0 <= ny && ny < m && !vis[nx][ny] && !prune(t - cur - 1, nx, ny)) {
				vis[nx][ny] = true;
				ans.emplace_back(nx, ny);
				rec(rec, cur + 1, nx, ny);
				vis[nx][ny] = false;
				ans.pop_back();
			}
		}
	};
	rec(rec, 0, 0, 0);
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3460kb

input:

8 8 16

output:

2 3
3 5
4 7
6 8
8 7
7 5
8 3
7 1
5 2
6 4
7 6
8 4
6 3
5 5
6 7
8 8

result:

ok correct

Test #2:

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

input:

8 8 32

output:

2 3
3 5
4 7
6 8
8 7
7 5
8 3
7 1
5 2
6 4
7 6
8 4
7 2
5 1
6 3
8 2
6 1
7 3
8 5
6 6
7 8
8 6
7 4
6 2
4 1
5 3
6 5
7 7
5 6
4 8
6 7
8 8

result:

ok correct

Test #3:

score: 0
Accepted
time: 1ms
memory: 3480kb

input:

8 8 48

output:

2 3
3 5
4 7
6 8
8 7
7 5
8 3
7 1
5 2
6 4
7 6
8 4
7 2
5 1
6 3
8 2
6 1
7 3
8 5
6 6
7 8
8 6
7 4
6 2
4 1
5 3
6 5
7 7
5 6
4 4
3 2
1 3
2 5
3 7
5 8
4 6
5 4
4 2
2 1
3 3
4 5
5 7
3 6
2 4
4 3
5 5
6 7
8 8

result:

ok correct

Test #4:

score: 0
Accepted
time: 1ms
memory: 3440kb

input:

9 8 17

output:

2 3
3 5
4 7
6 8
8 7
9 5
8 3
9 1
7 2
8 4
9 6
7 5
9 4
8 2
7 4
8 6
9 8

result:

ok correct

Test #5:

score: 0
Accepted
time: 1ms
memory: 3472kb

input:

9 8 35

output:

2 3
3 5
4 7
6 8
8 7
9 5
8 3
9 1
7 2
8 4
9 6
7 5
9 4
8 2
6 1
7 3
8 5
9 7
7 6
8 8
6 7
8 6
7 4
9 3
8 1
6 2
4 1
5 3
6 5
4 4
5 6
3 7
5 8
7 7
9 8

result:

ok correct

Test #6:

score: -100
Time Limit Exceeded

input:

9 8 53

output:


result: