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>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
#define int ll
#define fore(a, b, c) for(int a=b; a<c; ++a)
#define vi vector<int>
#define pb push_back
#define ii pair<int,int>
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define dbg(x) cerr << #x << ": " << x << endl
#define raya cerr << "========================" << endl
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int H = 3003;
char g[H][H];
int Is[H][H];
int h, w;
signed main(){
cin >> h >> w;
fore(i, 0, h){
fore(j, 0, w){
cin >> g[i][j];
}
}
// cuantos Is hay debajo de J
fore(j, 0, w){
for(int i=h-1; i>=0; --i){
Is[i][j] = Is[i+1][j];
Is[i][j] += (g[i][j] == 'I');
}
}
int ans = 0;
fore(i, 0, h){
int sumaIs = 0;
fore(j, 0, w){
if(g[i][j] == 'J'){
sumaIs += Is[i][j];
}
if(g[i][j] == 'O'){
ans += sumaIs;
}
}
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |