QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#328205 | #833. Cells Blocking | Terdy | WA | 1ms | 3704kb | C++14 | 1.4kb | 2024-02-15 18:15:01 | 2024-02-15 18:15:02 |
Judging History
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'