이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int H, W;
cin>>H>>W;
vector<int> O[H];
vector<int> I[W];
vector<pii> J;
for(int i=0;i<H;i++) {
string s;
cin>>s;
for(int j=0;j<W;j++) {
if(s[j]=='O') O[i].push_back(j);
else if(s[j]=='I') I[j].push_back(i);
else J.push_back({i, j});
}
}
ll ans = 0;
for(pii j:J) {
ll o = O[j.f].end()-upper_bound(O[j.f].begin(), O[j.f].end(), j.s);
ll
i = I[j.s].end()-upper_bound(I[j.s].begin(), I[j.s].end(), j.f);
ans += i*o;
}
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... |