Submission #547839

#TimeUsernameProblemLanguageResultExecution timeMemory
547839Zhora_004Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
201 ms89512 KiB
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cmath> #include <algorithm> #include <vector> #include <set> #include <unordered_set> #include <queue> #include <deque> #include <string> #include <sstream> #include <iomanip> #include <map> #include <unordered_map> #include <stack> #include <cstdio> #include <climits> #include <tuple> #include <ctime> #include <cstring> #include <numeric> #include <functional> #include <chrono> #include <cassert> #include <bitset> //#include <bit> //#include <ranges> //#include <numbers> #define itn int #define sacnf scanf #define sz(a) ((int)((a).size())) // printf("%.10f\n", ans); using ll = long long; using namespace std; const ll mod = 998244353; const int N = 1e6 + 1, inf = 1e9; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector<string> v(n); for (int i = 0; i < n; i++) cin >> v[i]; vector<vector<int>> O(n, vector<int>(m)); for (int i = 0; i < n; i++) { if (v[i][m - 1] == 'O') O[i][m - 1] = 1; for (int j = m - 2; j >= 0; j--) { O[i][j] = O[i][j + 1]; if (v[i][j] == 'O') O[i][j]++; } } vector<vector<int>> I(m, vector<int>(n)); for (int j = 0; j < m; j++) { if (v[n - 1][j] == 'I') I[j][n - 1] = 1; for (int i = n - 2; i >= 0; i--) { I[j][i] = I[j][i + 1]; if (v[i][j] == 'I') I[j][i]++; } } ll ans = 0; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (v[i][j] == 'J' && i + 1 < n && j + 1 < m) ans += 1ll * O[i][j + 1] * I[j][i + 1]; cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...