Submission #955158

#TimeUsernameProblemLanguageResultExecution timeMemory
955158hoanganh_siuuuuuuuuBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
305 ms220824 KiB
#include <bits/stdc++.h> #define int long long #define f(i, a, b) for(int i = a; i <= b; i++) #define fr(i, a, b) for(int i = a; i >= b; i--) #define pii pair <int, int> #define fi first #define se second #define pb push_back #define eb emplace_back #define in insert #define vvec vector<vector<int>> #define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0) using namespace std; const int N = 3003; int n, m, cnt[N][N], cnt2[N][N], a[N][N]; signed main() { fast; cin >> n >> m; f(i, 1, n) f(j, 1, m) { char kt; cin >> kt; if(kt == 'J') a[i][j] = 1; else if(kt == 'O') a[i][j] = 2; else a[i][j] = 3; } f(i, 1, n) fr(j, m, 1) cnt[i][j] = (a[i][j] == 2) + cnt[i][j + 1]; fr(i, n, 1) f(j, 1, m) cnt2[i][j] = (a[i][j] == 3) + cnt2[i + 1][j]; int res = 0; f(i, 1, n) f(j, 1, m) if(a[i][j] == 1) res += cnt[i][j] * cnt2[i][j]; cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...