# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
411786 | kimbj0709 | Bitaro the Brave (JOI19_ho_t1) | C++14 | 456 ms | 218240 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define maxn 3050
int pref1[maxn][maxn];
int pref2[maxn][maxn];
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n,m;
cin >> n >> m;
memset(pref1,0,sizeof(pref1));
memset(pref2,0,sizeof(pref2));
char input;
vector<pair<int,int> > pos;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin >> input;
if(input=='I'){
pref2[i][j] = 1;
}
else if(input=='J'){
pos.push_back({i,j});
}
else if(input=='O'){
pref1[i][j] = 1;
}
}
}
for(int i=0;i<maxn;i++){
for(int j=maxn-2;j>=0;j--){
pref1[i][j] += pref1[i][j+1];
pref2[j][i] += pref2[j+1][i];
}
}
int ans = 0;
for(int i=0;i<pos.size();i++){
ans += pref1[pos[i].f][pos[i].s]*pref2[pos[i].f][pos[i].s];
//cout << pos[i].f << " " << pos[i].s << " " << pref1[pos[i].f][pos[i].s]*pref2[pos[i].f][pos[i].s] << "\n";
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |