简答题
偏难
#12919
L形硬币
L形硬币


答案与解析
正确答案:<pre class="brush:cpp;toolbar:false">#include <iostream>
#include <string>
using namespace std;
const int MAXN = 2005;
int row[MAXN], col[MAXN];
string grid[MAXN];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
for(int i = 0; i < n; ++i)
{
cin >> grid[i];
for(int j = 0; j < n; ++j)
{
if(grid[i][j] == 'o')
{
row[i]++;
col[j]++;
}
}
}
long long ans = 0; // 防止int溢出,2000*2000量级乘积会超int范围
for(int i = 0; i < n; ++i)
{
for(int j = 0; j < n; ++j)
{
if(grid[i][j] == 'o')
ans += 1LL * (row[i] - 1) * (col[j] - 1);
}
}
cout << ans << '\n';
return 0;
}</pre>
这道题暂未补解析。