Submission #734068

#TimeUsernameProblemLanguageResultExecution timeMemory
734068LCJLYBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
368 ms159384 KiB
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int,int>pii; int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); int r,c; cin >> r >> c; char arr[r+5][c+5]; for(int x=1;x<=r;x++){ for(int y=1;y<=c;y++){ cin >> arr[x][y]; } } //compute psum int horizontal[r+5][c+5]; memset(horizontal,0,sizeof(horizontal)); for(int x=1;x<=r;x++){ for(int y=c;y>=1;y--){ horizontal[x][y]=horizontal[x][y+1]+(arr[x][y]=='O'); } } int vertical[r+5][c+5]; memset(vertical,0,sizeof(vertical)); for(int x=1;x<=c;x++){ for(int y=r;y>=1;y--){ vertical[y][x]=vertical[y+1][x]+(arr[y][x]=='I'); } } int counter=0; for(int x=1;x<=r;x++){ for(int y=1;y<=c;y++){ if(arr[x][y]=='J'){ counter+=horizontal[x][y]*vertical[x][y]; } } } cout << counter; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...