Submission #1001330

#TimeUsernameProblemLanguageResultExecution timeMemory
1001330ivan_alexeevBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
142 ms88716 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define ordered_set tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2,bmi2,fma,popcnt") #ifdef lisie_bimbi #define debug(x) cout << #x << " : " << x << endl; #else #define debug(x) ; #define endl '\n' #endif //#define int long long #define inf 1000000000 #define double long double typedef long long ll; #ifdef lisie_bimbi const int MAXC = 5; #else const int MAXC = 505; #endif signed main(){ #ifdef lisie_bimbi freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else ios_base::sync_with_stdio(false); cin.tie(nullptr); #endif int n, m; cin >> n >> m; vector<vector<char>> c(n, vector<char>(m)); for(int i = 0; i < n; i++){ string s; cin >> s; for(int j = 0; j < m; j++){ c[i][j] = s[j]; } } vector<vector<int>> oo(n, vector<int>(m)), ii(n, vector<int>(m)); for(int i = 0; i < n; i++){ oo[i][m - 1] = (c[i][m - 1] == 'O'); for(int j = m - 2; j >= 0; j--){ oo[i][j] = oo[i][j + 1] + (c[i][j] == 'O'); } } for(int j = 0; j < m; j++){ ii[n - 1][j] = (c[n - 1][j] == 'I'); for(int i = n - 2; i >= 0; i--){ ii[i][j] = ii[i + 1][j] + (c[i][j] == 'I'); } } ll ans = 0; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ if(c[i][j] == 'J') { ans += (ll) oo[i][j] * (ll) ii[i][j]; } } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...