Submission #481110

# Submission time Handle Problem Language Result Execution time Memory
481110 2021-10-19T13:42:58 Z dolamanee Tracks in the Snow (BOI13_tracks) C++14
Compilation error
0 ms 0 KB
// Created by ...
#include <bits/stdc++.h>

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pii pair<ll,ll>
#define vec(a) vector<a >
#define all(a) (a).begin(),(a).end()
#define se second
#define fi first
#define inf 0xffffffff
#define int long long
#define endl '\n'
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,b,a) for(ll i=b;i>=a;--i)
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define EACH(x, a) auto _Itr=begin(a);for (auto x=*_Itr;_Itr!=end(a);_Itr=next(_Itr),x=*_Itr)

using namespace std;
using ll = long long;
using ld = long double;
ll md = MD;

template<class... Args> auto Vec(size_t n, Args&&... args) {
	if constexpr(sizeof...(args) == 1)return vector(n, args...);
	else return vector(n, Vec(args...));
}
template<class T, class... Args> void DBS(T t, Args... args) {
	cerr << t;
	if constexpr(sizeof...(args) == 0) cerr << "]\n";
	else cerr << ", ", DBS(args...);
}
#ifdef _DEBUG
#define db(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBS(__VA_ARGS__)
#else
#define db(...) 0
#endif

ll exp(ll a, ll b) {ll r = 1ll; while (b > 0) {if (b & 1) {r = r * (a % md); r = (r + md) % md;} b >>= 1; a = (a % md) * (a % md); a = (a + md) % md;} return (r + md) % md;}
ll gcd(ll a, ll b) {if (b == 0)return a; return gcd(b, a % b);}
template<class T> T Min(T a, T b) {if (a < b)return a; return b;}
template<class T> T Max(T a, T b) {if (a > b)return a; return b;}
const int Mx = 4005;
char grid[Mx][Mx];
int h, w, vis[Mx][Mx];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
void solve() {
	cin >> h >> w;
	rep(i, 0, h - 1)rep(j, 0, w - 1)cin >> grid[i][j];
	queue<pii> q[2];
	char curr = grid[0][0];
	int id = (curr == 'F' ? 0 : 1), ans = 1;
	q[id].push({0, 0});
	while (!q[0].empty() || !q[1].empty()) {
		if (q[id].empty()) {
			++ans;
			id ^= 1;
			if (curr == 'F')curr = 'R';
			else curr = 'F';
		}
		while (!q[id].empty()) {
			auto [x, y] = q[id].front(); q[id].pop();
			vis[x][y] = 1;
			for (int i = 0; i < 4; ++i) {
				int nx = x + dx[i], ny = y + dy[i];
				if (nx < 0 || ny < 0 || nx >= h || ny >= w || vis[nx][ny] || grid[nx][ny] == '.')continue;
				vis[nx][ny] = 1;
				if (grid[nx][ny] == curr)q[id].push({nx, ny});
				else q[id ^ 1].push({nx, ny});
			}
		}
	}
	cout << ans;
}

int32_t main() {
	IOS;

	int t = 1;
	//cin>>t;
	while (t--) {
		solve();
	}
	return 0;
}

Compilation message

tracks.cpp: In function 'auto Vec(size_t, Args&& ...)':
tracks.cpp:29:5: warning: 'if constexpr' only available with '-std=c++17' or '-std=gnu++17'
   29 |  if constexpr(sizeof...(args) == 1)return vector(n, args...);
      |     ^~~~~~~~~
tracks.cpp:29:49: error: missing template arguments before '(' token
   29 |  if constexpr(sizeof...(args) == 1)return vector(n, args...);
      |                                                 ^
tracks.cpp:30:20: error: missing template arguments before '(' token
   30 |  else return vector(n, Vec(args...));
      |                    ^
tracks.cpp: In function 'void DBS(T, Args ...)':
tracks.cpp:34:5: warning: 'if constexpr' only available with '-std=c++17' or '-std=gnu++17'
   34 |  if constexpr(sizeof...(args) == 0) cerr << "]\n";
      |     ^~~~~~~~~
tracks.cpp: In function 'void solve()':
tracks.cpp:67:9: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   67 |    auto [x, y] = q[id].front(); q[id].pop();
      |         ^