Submission #139591

#TimeUsernameProblemLanguageResultExecution timeMemory
139591mechfrog88Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
634 ms151416 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("unroll-loops,no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; typedef long long ll; typedef long double ld; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); ll n,m; cin >> n >> m; vector <string> grid(n); for (int z=0;z<n;z++){ cin >> grid[z]; } vector <vector<ll>> hori(n,vector<ll>(m,0)); vector <vector<ll>> vert(n,vector<ll>(m,0)); for (int z=0;z<n;z++){ for (int x=m-1;x>-1;x--){ if (grid[z][x] == 'O'){ hori[z][x]++; } if (x != m-1) hori[z][x] += hori[z][x+1]; } } for (int z=0;z<m;z++){ for (int x=n-1;x>-1;x--){ if (grid[x][z] == 'I'){ vert[x][z]++; } if (x != n-1) vert[x][z] += vert[x+1][z]; } } ll ans = 0; for (int z=0;z<n;z++){ for (int x=0;x<m;x++){ if (grid[z][x] == 'J'){ ans += vert[z][x]*hori[z][x]; } } } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...