Submission #1264311

#TimeUsernameProblemLanguageResultExecution timeMemory
1264311witek_cppBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
196 ms80036 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; #define st first #define nd second #define f(a, c, b) for (int a = c; b > a; a++) #define pb push_back #define all(a) a.begin(), a.end() #define wczytaj(a, c, n) a.resize(n); f(i, c, n) cin >> a[i]; #define sz(a) int(a.size()) #define wypisz(a, c) f(i, c, sz(a)) cout << a[i] << " "; cout << "\n"; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int h, w; cin >> h >> w; vector<vector<char>> plansza(h, vector<char>(w)); f(i, 0, h) f(j, 0, w) cin >> plansza[i][j]; vector<vector<int>> pref_o(h, vector<int>(w, 0)); vector<vector<int>> pref_i(h, vector<int>(w, 0)); f(i, 0, h) { for (int j = w- 1; j >= 0; j--) { if (j != w-1) { pref_o[i][j] = pref_o[i][j + 1]; } if (plansza[i][j] == 'O') { pref_o[i][j]++; } } } for (int i = h - 1; i >= 0; i--) { f(j, 0, w) { if (i != h -1) { pref_i[i][j] = pref_i[i + 1][j]; } if (plansza[i][j] == 'I') { pref_i[i][j]++; } } } ll wnk = 0; f(i, 0, h) { f(j, 0, w) { if (plansza[i][j] == 'J') wnk += ll(pref_o[i][j]) * ll(pref_i[i][j]); } } cout << wnk << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...