이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define MS(x,y) memset((x),(y),sizeof((x)))
#define MN 1000000007
using namespace std;
char mat[3001][3001];
ll oDesno[3001][3001];
ll iDole[3001][3001];
ll getO (ll i, ll j) {
if (j != 0) return oDesno[i][j-1];
else return 0;
}
ll getI (ll i, ll j) {
if (i != 0) return iDole[i-1][j];
else return 0;
}
int main()
{
#if LOCAL_DEBUG
fstream cin("in.txt");
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n,m;
cin>>n>>m;
for (ll i = 0; i<n; i++) {
for (ll j = 0; j<m; j++) {
cin>>mat[i][j];
oDesno[i][j] = (mat[i][j] == 'O') + getO(i,j);
iDole[i][j] = (mat[i][j] == 'I') + getI(i,j);
}
}
ll res = 0;
for (ll i = 0; i<n; i++) {
for (ll j = 0; j<m; j++) {
if (mat[i][j] != 'J') continue;
res += (oDesno[i][m-1]-oDesno[i][j]) * (iDole[n-1][j]-oDesno[i][j]);
}
}
cout<<res<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |