이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int long long
#define nl '\n'
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
mt19937 rng((unsigned)chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1000000007, mod2 = 998244353;
// change this
const int N = 3005;
int n, m, ao[N][N], ai[N][N], ans;
char arr[N][N];
signed main() {
io;
cin >> n >> m;
for (int i=1; i<=n; i++) {
for (int j=1; j<=m; j++) {
cin >> arr[i][j];
if (arr[i][j] == 'O') ao[i][j]++;
else if (arr[i][j] == 'I') ai[i][j]++;
ao[i][j] += ao[i][j-1];
ai[i][j] += ai[i-1][j];
}
}
for (int i=1; i<=n; i++) {
for (int j=1; j<=n; j++) {
if (arr[i][j] != 'J') continue;
int x = ao[i][m] - ao[i][j], y = ai[n][j] - ai[i][j];
ans += x * y;
}
}
cout << ans << nl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |