Submission #782892

#TimeUsernameProblemLanguageResultExecution timeMemory
782892acatmeowmeowBitaro the Brave (JOI19_ho_t1)C++11
50 / 100
909 ms274432 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 3e3 + 5; int n, m, arr[N][N]; vector<int> row[N][5], col[N][5]; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { char ch; cin >> ch; if (ch == 'J') arr[i][j] = 0; else if (ch == 'O') arr[i][j] = 1; else arr[i][j] = 2; row[i][arr[i][j]].push_back(j); col[j][arr[i][j]].push_back(i); } } for (int i = 1; i <= n; i++) { for (int j = 0; j < 3; j++) { sort(row[i][j].begin(), row[i][j].end()); } } for (int j = 1; j <= m; j++) { for (int i = 0; i < 3; i++) { sort(col[j][i].begin(), col[j][i].end()); } } int ans = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (arr[i][j]) continue; int cntO = row[i][1].end() - upper_bound(row[i][1].begin(), row[i][1].end(), j); int cntI = col[j][2].end() - upper_bound(col[j][2].begin(), col[j][2].end(), i); ans += cntO*cntI; } } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...