제출 #1197998

#제출 시각아이디문제언어결과실행 시간메모리
1197998apelpisiaBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
189 ms151308 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int nx =3005; string grid[nx]; int h, w, qso[nx][nx], qsi[nx][nx], ans = 0; signed main(){ cin.tie(NULL)->sync_with_stdio(false); cin >> h >> w; for(int i=1; i<=h; i++){ cin >> grid[i]; for(int j=0; j<w; j++){ if(grid[i][j]=='O'){ // cout << "O\n"; qso[i][j+1]++; } else if(grid[i][j]=='I'){ // cout << "I\n"; qsi[i][j+1]++; } qso[i][j+1]+=qso[i][j]; qsi[i][j+1]+=qsi[i-1][j+1]; } } for(int i=1; i<=h; i++){ for(int j=0; j<w; j++){ if(grid[i][j]=='J'){ ans+=((qso[i][w] - qso[i][j+1])*(qsi[h][j+1] - qsi[i][j+1])); // cout << "i = " << i << " j = " << j+1 << "\n"; // cout << qso[i][w] << ' ' << qso[i][j+1] << ' ' << qsi[h][j+1] << ' ' << qsi[i][j+1] << "\n"; } } } cout << ans; // for(int i=1; i<=h; i++){ // for(int j=1; j<=w; j++) cout << qso[i][j] << ' '; // cout << "\n"; // } // cout << "----------------------------\n"; // for(int i=1; i<=h; i++){ // for(int j=1; j<=w; j++) cout << qsi[i][j] << ' '; // cout << "\n"; // } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...