제출 #1130297

#제출 시각아이디문제언어결과실행 시간메모리
1130297minggaBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
352 ms247440 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 ll long long const int MOD = 1e9 + 7; const int inf = 2e9; const int N = 3005; int h, w, a[N][N]; ll 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]--; } } } ll 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...