제출 #418278

#제출 시각아이디문제언어결과실행 시간메모리
418278AutumnBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
328 ms156108 KiB
#include <bits/stdc++.h> using namespace std; #define int int64_t void calc(vector<vector<int>> &aha, int h, int w, bool how){ if(how){ for(int i=h-1;i>=0;i--){ for(int j=w-2;j>=0;j--){ aha[i][j]+=aha[i][j+1]; } } return; } for(int i=w-1;i>=0;i--){ for(int j=h-2;j>=0;j--){ aha[j][i]+=aha[j+1][i]; } } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); int h,w; cin>>h>>w; vector<string> grid(h); vector<vector<int>> orbs(h,vector<int> (w,0)); vector<vector<int>> ingots(h,vector<int> (w,0)); for(int i=0;i<h;i++){ cin>>grid[i]; for(int j=0;j<w;j++){ if(grid[i][j]=='O'){ orbs[i][j]++; }else if(grid[i][j]=='I'){ ingots[i][j]++; } } } calc(orbs,h,w,true); calc(ingots,h,w,false); int sum=0; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(grid[i][j]=='J'){ sum+=orbs[i][j]*ingots[i][j]; } } } cout<<sum<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...