Submission #626068

#TimeUsernameProblemLanguageResultExecution timeMemory
626068l_rehoBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
145 ms18968 KiB
#include <bits/stdc++.h> using namespace std; int H, W; vector<string> V; void solve(){ cin>>H>>W; V.assign(H, ""); for(int i = 0; i < H; i++) cin>>V[i]; long long ans = 0; vector<int> orbInRow(H, 0), ingotInCol(W, 0); for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) orbInRow[i] += V[i][j] == 'O'; for(int i = 0; i < W; i++) for(int j = 0; j < H; j++) ingotInCol[i] += V[j][i] == 'I'; for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ if(V[i][j] == 'O') orbInRow[i]--; if(V[i][j] == 'I') ingotInCol[j]--; if(V[i][j] != 'J') continue; // mi servono gli ingot sotto i ans += (long long)orbInRow[i] * (long long)ingotInCol[j]; // cout<<"DEBUG-->"<<i+1<<" "<<j+1<<" "<<orbInRow[i] * ingotInCol[j]<<endl; } } cout<<ans<<endl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...