QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#328080#833. Cells BlockingKazdaleCompile Error//C++142.5kb2024-02-15 16:55:532024-02-15 16:55:55

Judging History

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

  • [2024-02-15 16:55:55]
  • 评测
  • [2024-02-15 16:55:53]
  • 提交

answer

#include <iostream>
#include <vector>
#define int long long
using namespace std;
constexpr int MAXN(3007);
vector <int> lmx, lmy;
int xx[] = {0, 1};
int yy[] = {1, 0};
char ch[MAXN][MAXN];
int a[MAXN][MAXN], b[MAXN][MAXN], c[MAXN][MAXN], d[MAXN][MAXN];
int qx[MAXN * MAXN], qy[MAXN * MAXN], head, tail;
int n, m, ept, jiao, njiao;
long long ans;
inline void read(int &temp) { cin >> temp; }
inline void bfs1() {
	head = 1, tail = 0;
	qx[++tail] = 1, qy[tail] = 1, a[1][1] = 1;
	while (head <= tail) {
		int nx = qx[head], ny = qy[head++];
		for (int i(0); i < 2; ++i) {
			int tx = nx + xx[i], ty = ny + yy[i];
			if (tx > n || ty > m || ch[tx][ty] == '*')  continue;
			if (!a[tx][ty])  qx[++tail] = tx, qy[tail] = ty;
			a[tx][ty] = 1;
		}
	}
}
inline void bfs2() {
	head = 1, tail = 0;
	qx[++tail] = n, qy[tail] = m, b[n][m] = 1;
	while (head <= tail) {
		int nx = qx[head], ny = qy[head++];
		for (int i(0); i < 2; ++i) {
			int tx = nx - xx[i], ty = ny - yy[i];
			if (tx < 1 || ty < 1 || ch[tx][ty] == '*')  continue;
			if (!b[tx][ty])  qx[++tail] = tx, qy[tail] = ty;
			b[tx][ty] = 1;
		}
	}
}
void leftmost(int x, int y, int dt) {
	if (dt)  ++c[x][y], lmx.emplace_back(x), lmy.emplace_back(y);
	if (d[x][y] && !c[x][y])  ++njiao;
	if (x == n && y == m)  return ;
	if (b[x + 1][y])  return leftmost(x + 1, y, dt);
	return leftmost(x, y + 1, dt);
}
void rightmost(int x, int y) {
	++d[x][y];
	if (c[x][y])  ++jiao;
	if (x == n && y == m)  return ;
	if (b[x][y + 1])  return rightmost(x, y + 1);
	return rightmost(x + 1, y);
}
void nlm(int x, int y) {
	if (d[x][y] && !c[x][y])  ++njiao;
	if (x == 1 && y == 1)  return ;
	if (a[x][y - 1])  return nlm(x, y - 1);
	return nlm(x - 1, y);
}
signed main() {
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	read(n), read(m);
	for (int i(1); i <= n; ++i)
		for (int j(1); j <= m; ++j)  cin >> ch[i][j];
	for (int i(1); i <= n; ++i)
		for (int j(1); j <= m; ++j)  if (ch[i][j] == '.')  ++ept;
	bfs1(), bfs2();
	if (!a[n][m])  return cout << max(ept * (ept - 1) / 2, 0) << endl, 0;
	leftmost(1, 1, 1), rightmost(1, 1);
	ans = jiao * (ept - jiao) + jiao * (jiao - 1) / 2;
	for (int i(0); i < (int)lmx.size(); ++i) {
		int x = lmx[i], y = lmy[i];
		if (d[x][y])  continue;
		njiao = 0;
		for (int j(1); x - j >= 1 && y + j <= m; ++j) {
			if (a[x - j][y + j] && b[x - j][y + j]) {
				leftmost(x - j, y + j, 0), nlm(x - j, y + j);
				ans += njiao - d[x - j][y + j];
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:69:42: error: no matching function for call to ‘max(long long int, int)’
   69 |         if (!a[n][m])  return cout << max(ept * (ept - 1) / 2, 0) << endl, 0;
      |                                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/string:51,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
answer.code:69:42: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   69 |         if (!a[n][m])  return cout << max(ept * (ept - 1) / 2, 0) << endl, 0;
      |                                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
answer.code:69:42: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   69 |         if (!a[n][m])  return cout << max(ept * (ept - 1) / 2, 0) << endl, 0;
      |                                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~