이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
/*struct O
{
int l,i;
bool operator<(const O&o)const{
return l<o.l;
}
};
struct I
{
int k,j;
bool operator<(const I&o)const{
return k<o.k;
}
};*/
char t[3333][3333];
int qso[3333][3333];
int qsi[3333][3333];
queue<pair<int,int>> J;
int main()
{
cin.tie()->sync_with_stdio(0);
int r,c;cin>>r>>c;
for(int i= 1;i<=r;i++)
for(int j=1;j<=c;j++)
{
cin>>t[i][j];
if(t[i][j]=='J')
J.push({i,j});
else if(t[i][j]=='O')
qso[i][j]=1;
else
qsi[i][j]=1;
}
long long ans=0;
for(int i=1;i<=r;i++)
{
for(int j=1;j<=c;j++)
{
qso[i][j]+=qso[i][j-1];
qsi[i][j]+=qsi[i-1][j];
}
}
while(!J.empty())
{
pair<int,int> now=J.front();
// cout<<now.first<<' '<<now.second<<'\n';
J.pop();
ans+=(qso[now.first][c]-qso[now.first][now.second])*(qsi[r][now.second]-qsi[now.first][now.second]);
}
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... |