Submission #818865

#TimeUsernameProblemLanguageResultExecution timeMemory
818865vjudge1Bitaro the Brave (JOI19_ho_t1)C++17
50 / 100
264 ms274432 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define se second #define fi first #define pii pair<int,int> #define pll pair<long long, long long> ll h,w,power=0; vector<vector<char>> thingy; pll os[3000][3000]; void solve(){ memset(os,0,sizeof(os)); cin >> h >> w; for(int i=0; i<h; i++){ vector<char> bruh; for(int j=0; j<w; j++){ char temp; cin >> temp; bruh.push_back(temp); } thingy.push_back(bruh); } for(int i=h-1; i>=0; i--){ for(int j=w-1; j>=0; j--){ if(thingy[i][j]=='I'){ if(i==h-1){ os[i][j].fi=1; os[i][j].se=0; }else{ os[i][j].fi=os[i+1][j].fi+1; os[i][j].se=os[i][j+1].se; } }else if(thingy[i][j]=='O'){ if(j==w-1){ os[i][j].se=1; os[i][j].fi=0; }else{ os[i][j].se=os[i][j+1].se+1; os[i][j].fi=os[i+1][j].fi; } }else{ if(j==w-1){ os[i][j].se=0; }else{ os[i][j].se=os[i][j+1].se; } if(i==h-1){ os[i][j].fi=0; }else{ os[i][j].fi=os[i+1][j].fi; } } } } for(int i=0; i<h; i++){ for(int j=0; j<w; j++){ if(thingy[i][j]=='J'){ power+= os[i][j].fi*os[i][j].se; } } } cout << power << endl; return; } int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...