QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#181473#7226. The Impressive Pathucup-team288Compile Error//C++142.2kb2023-09-16 19:26:492023-09-16 19:26:49

Judging History

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

  • [2023-09-16 19:26:49]
  • 评测
  • [2023-09-16 19:26:49]
  • 提交

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);

	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	{
		vector<int> o(8);
		iota(o.begin(), o.end(), 0);
		shuffle(o.begin(), o.end(), rng);
		vector<int> x(8), y(8);
		for (int i = 0; i < 8; i++) {
			x[i] = dx[o[i]];
			y[i] = dy[o[i]];
		}
		swap(x, dx), swap(y, dy);
	}

	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);
}

Details

answer.code: In function ‘int main()’:
answer.code:54:16: error: missing template arguments before ‘vis’
   54 |         vector vis(n, vector<int>(m));
      |                ^~~
answer.code:55:9: error: ‘vis’ was not declared in this scope
   55 |         vis[0][0] = true;
      |         ^~~