이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define endl "\n"
#define finp for(int i=0; i<n; i++)
#define fknp for(int k=0; k<n; k++)
#define yeap cout<<"YES"<<endl
#define nope cout<<"NO"<<endl
#define inpintn int n; cin>>n
#define inpintarrn int arr[n]; for(int i=0; i<n; i++){cin>>arr[i];}
#define inpllarrn long long arr[n]; for(int i=0; i<n; i++){cin>>arr[i];}
#define ll long long
using namespace std;
int main ()
{
ll h, w;
cin>>h>>w;
ll brr[h][w];
vector<pair<ll, ll>> v;
for(int i=0; i<h; i++){
string a;
cin>>a;
for(int j=0; j<w; j++){
if(a[j]=='J'){
brr[i][j] = 1;
v.push_back({i, j});
} else if(a[j]=='O'){
brr[i][j] = 2;
} else {
brr[i][j] = 3;
}
}
}
ll orr[h][w];
for(int i=0; i<h; i++){
ll cnto = 0;
for(int j=w-1; j>=0; j--){
if(brr[i][j]==2){
cnto++;
orr[i][j] = cnto;
} else {
orr[i][j] = cnto;
}
}
}
ll irr[h][w];
for(int i=0; i<w; i++){
ll cnti = 0;
for(int j=h-1; j>=0; j--){
if(brr[j][i]==3){
cnti++;
irr[j][i] = cnti;
} else {
irr[j][i] = cnti;
}
}
}
ll siz = v.size();
ll ans = 0;
for(int i=0; i<siz; i++){
ll aa = v[i].first;
ll bb = v[i].second;
ll cc = (orr[aa][bb])*(irr[aa][bb]);
ans = ans+cc;
}
cout<<ans<<endl;
// for(int i=0; i<h; i++){
// for(int j=0; j<w; j++){
// cout << orr[i][j] << " ";
// }
// cout<<endl;
// }
// for(int i=0; i<h; i++){
// for(int j=0; j<w; j++){
// cout << irr[i][j] << " ";
// }
// cout<<endl;
// }
// ll siz = v.size();
// for(int i=0; i<siz; i++){
// }
// cout<<endl;
// for(int i=0; i<h; i++){
// for(int j=0; j<w; j++){
// cout << brr[i][j] << " ";
// }
// cout<<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... |