Submission #245126

#TimeUsernameProblemLanguageResultExecution timeMemory
245126groeneprofBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
133 ms160120 KiB
#include <bits/stdc++.h> #define int long long #define P(x) do {if(debug) cout << x << endl;} while(false) #define H(x) P(#x << ": " << x) #define FR(i, a, b) for(int i = (a); i < (b); ++i) #define F(i, n) FR(i, 0, n) #define DR(i, a, b) for(int i = (b); i --> (a);) #define D(i, n) DR(i, 0, n) #define S(s) (int)(s).size() #define ALL(x) (x).begin(), (x).end() #define MI(x, a) (x) = min(x, a) #define MA(x, a) (x) = max(x, a) #define V vector #define pb push_back #define mp make_pair using namespace std; const bool debug = 1; const int inf = 1e18; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int h,w; cin>>h>>w; vector<string> grid(h); F(i,h){ cin>>grid[i]; } vector<vector<int> > O(h,vector<int> (w+1,0)); vector<vector<int> > I(h+1, vector<int> (w,0)); int ans = 0; for(int i = h-1; i>=0; i--){ for(int j = w-1; j>=0; j--){ O[i][j] = O[i][j+1] + (grid[i][j] == 'O'); I[i][j] = I[i+1][j] + (grid[i][j] == 'I'); ans+= (grid[i][j] == 'J') * O[i][j] * I[i][j]; } } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...