QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#328205#833. Cells BlockingTerdyWA 1ms3704kbC++141.4kb2024-02-15 18:15:012024-02-15 18:15:02

Judging History

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

  • [2024-02-15 18:15:02]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3704kb
  • [2024-02-15 18:15:01]
  • 提交

answer

# include <bits/stdc++.h>

using namespace std;

# define int long long

const int N = 3e3 + 5;
int n , m , cnt , ans , f[N][N] , g[N][N];
char mp[N][N];
vector< int > vec[N<<1];

signed main()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) cin >> mp[i][j] , cnt += mp[i][j] == '.';
	f[1][1] = mp[1][1] == '.';
	for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) if(mp[i][j] == '.') f[i][j] = f[i][j - 1] | f[i - 1][j];
	g[n][m] = mp[n][m] == '.';
	for(int i = n; i; i--) for(int j = m; j; j--) if(mp[i][j] == '.') g[i][j] = g[i][j + 1] | g[i + 1][j];
	if(!f[n][m]) return cout << cnt * (cnt - 1) / 2 , 0;
	for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) if(f[i][j] && g[i][j]) vec[i + j].push_back(i); else mp[i][j] = '*';
	for(int i = 2; i <= n + m; i++) if(vec[i].size() == 1) ans += --cnt;
	cout << ans << endl;
	for(int i = 2; i <= n + m; i++)
	{
		auto &v = vec[i];
		if(v.size() == 1) continue ;
		int l = v[1] , r = v[v.size() - 1];
		if(l == r) ans++;
		for(int j = i + 1; j <= n + m; j++)
		{
			if(mp[l][j - l] == '*') l++;
			if(mp[r + 1][j - (r + 1)] == '.') r++;
			if(l == r && vec[j].size() > 1) ans++;
		}
		l = v[0] , r = v[v.size() - 2];
		for(int j = i + 1; j <= n + m; j++)
		{
			if(mp[l][j - l] == '*') l++;
			if(mp[r + 1][j - (r + 1)] == '.') r++;
			if(l == r && vec[j].size() > 1) ans++;
		}
	}
	cout << ans;
	return 0;
}
/*
3 3
...
...
...
*/

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3704kb

input:

3 3
...
...
...

output:

36

result:

wrong answer 1st numbers differ - expected: '17', found: '36'