Submission #292439

#TimeUsernameProblemLanguageResultExecution timeMemory
292439jbroeksteegBitaro the Brave (JOI19_ho_t1)C++14
20 / 100
12 ms8064 KiB
#include <iostream> #include <climits> #include <numeric> #include <cassert> #include <algorithm> #include <queue> #include <map> #include <stack> #include <set> #include <vector> #include <array> #include <memory> #define IN(a,b) (a.find(b) != a.end()) #define p(a,b) make_pair(a,b) #define readVec(a) for (int __i = 0; __i<(int)a.size();__i++){cin>>a[__i];} // jimjam template<typename T> void pMin(T &a, T b) {if (b<a){a=b;}} template<typename T> void pMax(T &a, T b) {if (b>a){a=b;}} template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& c); template<typename A, typename B> std::ostream& operator<<(std::ostream& os, const std::pair<A,B>& c) {std::cout << "(" << c.first << ", " << c.second << ")";return os;} template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& c) { if (c.size() == 0) {os << "{}"; return os;} os << "{" << c[0]; for (int i = 1; i < (int)c.size(); i++) {os <<", "<<c[i];} os << "}"; return os; } using namespace std; #define MAXN 3001 char grid[MAXN][MAXN]; int ingotsBelow[MAXN][MAXN]; int orbsRight[MAXN][MAXN]; int main() { ios::sync_with_stdio(0); cin.tie(0); int rows, cols; cin >> rows >> cols; for (int r = 0; r < rows; r++) { for (int c = 0; c < cols; c++) { cin >> grid[r][c]; } } for (int c = 0; c < cols; c++) { for (int r = rows-1; r >= 0; r--) { ingotsBelow[r][c] += ingotsBelow[r+1][c]; ingotsBelow[r][c] += (grid[r][c]=='I'); } } for (int r = 0; r < rows; r++) { for (int c = cols-1; c >= 0; c--) { orbsRight[r][c] += orbsRight[r][c+1]; orbsRight[r][c] += (grid[r][c]=='O'); } } int ans=0; for (int r = 0; r < rows; r++) { for (int c = 0 ; c < cols ;c++) { if (grid[r][c]=='J') { ans += ingotsBelow[r][c]*orbsRight[r][c]; } } } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...