제출 #1130294

#제출 시각아이디문제언어결과실행 시간메모리
1130294minggaBitaro the Brave (JOI19_ho_t1)C++20
50 / 100
385 ms282572 KiB
#include "bits/stdc++.h" using namespace std; #define ln "\n" #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define int long long const int MOD = 1e9 + 7; const int inf = 2e18; const int N = 3005; int h, w, a[N][N], cnt[N][N][3]; signed main() { cin.tie(0) -> sync_with_stdio(0); cin >> h >> w; for(int i = 1; i <= h; i++) { for(int j = 1; j <= w; j++) { char c; cin >> c; if(c == 'I') { a[i][j] = 1; cnt[1][j][1]++; cnt[i][j][1]--; } else if(c == 'O') { a[i][j] = 2; cnt[i][1][2]++; cnt[i][j][2]--; } } } int ans = 0; for(int i = 1; i <= h; i++) { for(int j = 1; j <= w; j++) { cnt[i][j][1] = cnt[i - 1][j][1] + cnt[i][j][1]; cnt[i][j][2] = cnt[i][j - 1][2] + cnt[i][j][2]; } } for(int i = 1; i <= h; i++) { for(int j = 1; j <= w; j++) { if(a[i][j] == 0) { ans += cnt[i][j][2] * cnt[i][j][1]; } } } cout << ans << ln; cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...