Submission #381747

#TimeUsernameProblemLanguageResultExecution timeMemory
381747IwanttobreakfreeBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
323 ms107928 KiB
#include <iostream> #include <vector> using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); long long int h,w; cin>>h>>w; char grid[h][w]; int canti[h][w]; canti[0][0]=0; int canto[h][w]; canto[0][0]=0; vector<pair<int,int> > v; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(j==0)canto[i][j]=0; else canto[i][j]=canto[i][j-1]; if(i==0)canti[i][j]=0; else canti[i][j]=canti[i-1][j]; cin>>grid[i][j]; if(grid[i][j]=='J')v.push_back(make_pair(i,j)); else if(grid[i][j]=='O')canto[i][j]++; else canti[i][j]++; //cout<<canti[i][j]; } //cout<<'\n'; } int n=v.size(); long long int sol=0; for(int j=0;j<n;j++){ int x=v[j].first,y=v[j].second; int multi=canto[x][w-1]-canto[x][y]; int multo=canti[h-1][y]-canti[x][y]; sol+=multi*multo; } cout<<sol<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...