This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3", "inline")
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define ins insert
#define pb push_back
#define int long long
#define pii pair<int, int>
#define endl '\n'
#define drop(x) cout<<(x)<<endl;return;
#define reach cerr << "reached >.<!" << endl;
/*
m : 11059739 -> l ~23
p : 4567896467
*/
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1e9 + 7, sze = 1e6 + 50, inf = LLONG_MAX, prime = 2333;
//\\
dp / binary search / greedy / sprase table / segment tree
//
int rowo[sze];
int coli[sze];
void gkd(){
int n,m;
cin>>n>>m;
vector<vector<char>> arr(n+1,vector<char>(m+1));
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>arr[i][j];
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(arr[i][j]=='O'){
rowo[i]++;
}
else if(arr[i][j]=='I'){
coli[j]++;
}
}
}
int ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(arr[i][j]=='I'){
coli[j]--;
}
}
for(int j=1;j<=m;j++){
if(arr[i][j]=='J'){
// cout<<i<<" "<<j<<" "<<rowo[i]*coli[j]<<endl;
ans+= rowo[i] * coli[j];
}
else if(arr[i][j]=='O'){
rowo[i]--;
}
}
}
drop(ans);
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int tt = 1; //cin>>tt;
while (tt--)gkd();
}
Compilation message (stderr)
joi2019_ho_t1.cpp:19:1: warning: multi-line comment [-Wcomment]
19 | //\\
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |