Submission #768435

#TimeUsernameProblemLanguageResultExecution timeMemory
768435singlabharatBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
83 ms19068 KiB
// OM SHRI GANESHAY NAMAH // HARE KRISHNA #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define int long long using vi = vector<int>; using vs = vector<string>; using vb = vector<bool>; using vvi = vector<vector<int>>; using pii = pair<int, int>; using vpii = vector<pair<int, int>>; using si = set<int>; using mii = map<int, int>; template<typename T> using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define sz(x) (int)size(x) #define pb emplace_back #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) #define fr first #define sc second #define fo(i, end) for (int i = 0; i < end; i++) #define foo(i, start, end) for (int i = start; i < end; i++) template<typename T> inline void domin(T &x, T y) {if (y < x) x = y;} template<typename T> inline void domax(T &x, T y) {if (y > x) x = y;} template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template < typename T_container, typename T = typename enable_if < !is_same<T_container, string>::value, typename T_container::value_type >::type > ostream & operator<<(ostream &os, const T_container &a) { os << '{'; string sep; for (const T &x : a) os << sep << x, sep = ", "; return os << '}';} void debug() {cerr << endl;} template <typename Head, typename... Tail> void debug(Head h, Tail... t) {cerr << h << ' '; debug(t...);} #ifdef singlabharat #define debug(...) cerr << "(" << #__VA_ARGS__ << ") : ", debug(__VA_ARGS__) #else #define debug(...) #endif #define endl '\n' const int MX = 2e5 + 2, MOD = 1e9 + 7, INF = 1e18; void solve() { int n, m; cin >> n >> m; vs a(n); vi row(n), col(m); fo(i, n) { cin >> a[i]; for (char c : a[i]) row[i] += (c == 'O'); } fo(j, m) fo(i, n) col[j] += (a[i][j] == 'I'); int ans = 0; fo(i, n) { fo(j, m) { ans += (a[i][j] == 'J') * (row[i] * col[j]); row[i] -= (a[i][j] == 'O'); col[j] -= (a[i][j] == 'I'); } } cout << ans; } int32_t main() { #ifdef singlabharat freopen("error.txt", "w", stderr); #endif cin.tie(0)->sync_with_stdio(0); int t = 1; // cin >> t; for (int tc = 1; tc <= t; tc++) { // cout << "Case #" << tc << ": "; solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...