이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pb push_back
#define mp make_pair
const unsigned int mod = 1e9+7;
const int mx=1e5+5;
ll h,w;
char s[3001][3001];
ll row[3001][3001];
ll col[3001][3001];
int main(){
/*freopen("tavsan.gir", "r", stdin);
freopen("tavsan.cik", "w", stdout);
*/ios_base::sync_with_stdio(false);cin.tie(NULL);
cin >> h >> w;
ref(i,1,h)ref(j,1,w)cin >> s[i][j];
ref(i,1,h){
for(ll j=w;j>=1;--j){
row[i][j]=row[i][j+1]+(s[i][j]=='O');
}
}
ref(i,1,w){
for(ll j=h;j>=1;--j){
col[j][i]=col[j+1][i]+(s[j][i]=='I');
}
}
ll ans=0;
ref(i,1,h){
ref(j,1,w){
if(s[i][j]=='J'){
ans+=row[i][j+1]*col[i+1][j];
}
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |