이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl "\n"
llo mod=1000000007;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
//setIO("");
llo n,m;
cin>>n>>m;
char ss;
llo it[n][m];
for(llo i=0;i<n;i++){
for(llo j=0;j<m;j++){
cin>>ss;
if(ss=='J'){
it[i][j]=0;
}
else if(ss=='O'){
it[i][j]=1;
}
else{
it[i][j]=2;
}
}
}
llo pre[n][m];
for(llo i=0;i<n;i++){
for(llo j=m-1;j>=0;j--){
llo cc=0;
if(it[i][j]==1){
cc=1;
}
pre[i][j]=cc;
if(j<m-1){
pre[i][j]+=pre[i][j+1];
}
}
}
llo pre2[n][m];
for(llo j=0;j<m;j++){
for(llo i=n-1;i>=0;i--){
llo cc=0;
if(it[i][j]==2){
cc=1;
}
pre2[i][j]=cc;
if(i<n-1){
pre2[i][j]+=pre2[i+1][j];
}
}
}
llo tot=0;
for(llo i=0;i<n;i++){
for(llo j=0;j<m;j++){
if(it[i][j]==0){
tot+=pre[i][j]*pre2[i][j];
}
}
}
cout<<tot<<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... |