Submission #427267

# Submission time Handle Problem Language Result Execution time Memory
427267 2021-06-14T13:52:02 Z model_code Robot Race (CPSPC17_race) C++17
Compilation error
0 ms 0 KB
#include <bitset>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

const int MAXN = 1000;
const int MAXQ = 1000000;

int n, m, q;
bool empty[MAXN][MAXN];
bitset<MAXN> f[MAXN][MAXN], g[MAXN][MAXN];
int sr[MAXQ], sc[MAXQ], tr[MAXQ], tc[MAXQ];
bool ans[MAXQ];

void rec(int from, int to, const vector<int>& remain) {
	if (from > to) return;
	int mid = (from + to) / 2;
	for (int i = mid; i >= from; i--) {
		for (int j = m - 1; j >= 0; j--) {
			f[i][j] = 0;
			if (empty[i][j]) {
				if (i == mid) {
					f[i][j][j] = 1;
				} else {
					f[i][j] |= f[i + 1][j];
				}
				if (j != m - 1) {
					f[i][j] |= f[i][j + 1];
				}
			}
		}
	}
	for (int i = mid; i <= to; i++) {
		for (int j = 0; j < m; j++) {
			g[i][j] = 0;
			if (empty[i][j]) {
				if (i == mid) {
					g[i][j][j] = 1;
				} else {
					g[i][j] |= g[i - 1][j];
				}
				if (j != 0) {
					g[i][j] |= g[i][j - 1];
				}
			}
		}
	}
	vector<int> remain_left, remain_right;
	for (int i : remain) {
		if (tr[i] < mid) {
			remain_left.push_back(i);
		} else if (sr[i] > mid) {
			remain_right.push_back(i);
		} else {
			ans[i] = (f[sr[i]][sc[i]] & g[tr[i]][tc[i]]).any();
		}
	}
	rec(from, mid - 1, remain_left);
	rec(mid + 1, to, remain_right);
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> m >> q;
	assert(n >= 1 && n <= 1000);
	assert(m >= 1 && m <= 1000);
	assert(q >= 1 && q <= 1000000);
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		assert((int) s.length() == m);
		for (int j = 0; j < m; j++) {
			empty[i][j] = s[j] == '.';
		}
	}
	vector<int> remain(q);
	for (int i = 0; i < q; i++) {
		cin >> sr[i] >> sc[i] >> tr[i] >> tc[i];
		assert(sr[i] >= 1 && sr[i] <= n);
		assert(sc[i] >= 1 && sc[i] <= m);
		assert(tr[i] >= 1 && tr[i] <= n);
		assert(tc[i] >= 1 && tc[i] <= m);
		sr[i]--; sc[i]--; tr[i]--; tc[i]--;
		assert(empty[sr[i]][sc[i]]);
		assert(empty[tr[i]][tc[i]]);
		remain[i] = i;
	}
	rec(0, n - 1, remain);
	for (int i = 0; i < q; i++) {
		printf("%s\n", ans[i] ? "YES" : "NO");
	}
	return 0;
}

Compilation message

Main.cpp: In function 'void rec(int, int, const std::vector<int>&)':
Main.cpp:24:8: error: reference to 'empty' is ambiguous
   24 |    if (empty[i][j]) {
      |        ^~~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bitset:47,
                 from Main.cpp:1:
/usr/include/c++/10/bits/range_access.h:281:5: note: candidates are: 'template<class _Tp> constexpr bool std::empty(std::initializer_list<_Tp>)'
  281 |     empty(initializer_list<_Tp> __il) noexcept
      |     ^~~~~
/usr/include/c++/10/bits/range_access.h:272:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr bool std::empty(const _Tp (&)[_Nm])'
  272 |     empty(const _Tp (&)[_Nm]) noexcept
      |     ^~~~~
/usr/include/c++/10/bits/range_access.h:263:5: note:                 'template<class _Container> constexpr decltype (__cont.empty()) std::empty(const _Container&)'
  263 |     empty(const _Container& __cont) noexcept(noexcept(__cont.empty()))
      |     ^~~~~
Main.cpp:13:6: note:                 'bool empty [1000][1000]'
   13 | bool empty[MAXN][MAXN];
      |      ^~~~~
Main.cpp:39:8: error: reference to 'empty' is ambiguous
   39 |    if (empty[i][j]) {
      |        ^~~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bitset:47,
                 from Main.cpp:1:
/usr/include/c++/10/bits/range_access.h:281:5: note: candidates are: 'template<class _Tp> constexpr bool std::empty(std::initializer_list<_Tp>)'
  281 |     empty(initializer_list<_Tp> __il) noexcept
      |     ^~~~~
/usr/include/c++/10/bits/range_access.h:272:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr bool std::empty(const _Tp (&)[_Nm])'
  272 |     empty(const _Tp (&)[_Nm]) noexcept
      |     ^~~~~
/usr/include/c++/10/bits/range_access.h:263:5: note:                 'template<class _Container> constexpr decltype (__cont.empty()) std::empty(const _Container&)'
  263 |     empty(const _Container& __cont) noexcept(noexcept(__cont.empty()))
      |     ^~~~~
Main.cpp:13:6: note:                 'bool empty [1000][1000]'
   13 | bool empty[MAXN][MAXN];
      |      ^~~~~
Main.cpp: In function 'int main()':
Main.cpp:76:4: error: reference to 'empty' is ambiguous
   76 |    empty[i][j] = s[j] == '.';
      |    ^~~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bitset:47,
                 from Main.cpp:1:
/usr/include/c++/10/bits/range_access.h:281:5: note: candidates are: 'template<class _Tp> constexpr bool std::empty(std::initializer_list<_Tp>)'
  281 |     empty(initializer_list<_Tp> __il) noexcept
      |     ^~~~~
/usr/include/c++/10/bits/range_access.h:272:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr bool std::empty(const _Tp (&)[_Nm])'
  272 |     empty(const _Tp (&)[_Nm]) noexcept
      |     ^~~~~
/usr/include/c++/10/bits/range_access.h:263:5: note:                 'template<class _Container> constexpr decltype (__cont.empty()) std::empty(const _Container&)'
  263 |     empty(const _Container& __cont) noexcept(noexcept(__cont.empty()))
      |     ^~~~~
Main.cpp:13:6: note:                 'bool empty [1000][1000]'
   13 | bool empty[MAXN][MAXN];
      |      ^~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from Main.cpp:2:
Main.cpp:87:10: error: reference to 'empty' is ambiguous
   87 |   assert(empty[sr[i]][sc[i]]);
      |          ^~~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bitset:47,
                 from Main.cpp:1:
/usr/include/c++/10/bits/range_access.h:281:5: note: candidates are: 'template<class _Tp> constexpr bool std::empty(std::initializer_list<_Tp>)'
  281 |     empty(initializer_list<_Tp> __il) noexcept
      |     ^~~~~
/usr/include/c++/10/bits/range_access.h:272:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr bool std::empty(const _Tp (&)[_Nm])'
  272 |     empty(const _Tp (&)[_Nm]) noexcept
      |     ^~~~~
/usr/include/c++/10/bits/range_access.h:263:5: note:                 'template<class _Container> constexpr decltype (__cont.empty()) std::empty(const _Container&)'
  263 |     empty(const _Container& __cont) noexcept(noexcept(__cont.empty()))
      |     ^~~~~
Main.cpp:13:6: note:                 'bool empty [1000][1000]'
   13 | bool empty[MAXN][MAXN];
      |      ^~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from Main.cpp:2:
Main.cpp:88:10: error: reference to 'empty' is ambiguous
   88 |   assert(empty[tr[i]][tc[i]]);
      |          ^~~~~
In file included from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bitset:47,
                 from Main.cpp:1:
/usr/include/c++/10/bits/range_access.h:281:5: note: candidates are: 'template<class _Tp> constexpr bool std::empty(std::initializer_list<_Tp>)'
  281 |     empty(initializer_list<_Tp> __il) noexcept
      |     ^~~~~
/usr/include/c++/10/bits/range_access.h:272:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr bool std::empty(const _Tp (&)[_Nm])'
  272 |     empty(const _Tp (&)[_Nm]) noexcept
      |     ^~~~~
/usr/include/c++/10/bits/range_access.h:263:5: note:                 'template<class _Container> constexpr decltype (__cont.empty()) std::empty(const _Container&)'
  263 |     empty(const _Container& __cont) noexcept(noexcept(__cont.empty()))
      |     ^~~~~
Main.cpp:13:6: note:                 'bool empty [1000][1000]'
   13 | bool empty[MAXN][MAXN];
      |      ^~~~~