제출 #236941

#제출 시각아이디문제언어결과실행 시간메모리
236941AtalasionBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
316 ms80484 KiB
//khodaya khodet komak kon #include <bits/stdc++.h> #define F first #define S second #define pb push_back #define all(x) x.begin(), x.end() #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; const int N = 3000 + 10; const ll MOD = 1000000000 + 7; const ll INF = 1000000010; const ll LOG = 25; char grid[N][N]; int n, m, R[N][N], C[N][N]; int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++){ cin >> grid[i][j]; if (grid[i][j] == 'I') C[j][i] = 1; if (grid[i][j] == 'O') R[i][j] = 1; }; ll ans = 0; for (int i = 1; i <= n; i++) for (int j = m; j >= 1; j--) R[i][j] += R[i][j + 1]; for (int j = 1; j <= m; j++) for (int i = n; i >= 1; i--) C[j][i] += C[j][i + 1]; for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++){ if (grid[i][j] == 'J'){ ans += R[i][j + 1] * C[j][i + 1]; } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...