Submission #946304

#TimeUsernameProblemLanguageResultExecution timeMemory
946304attkyBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
379 ms158924 KiB
#include <bits/stdc++.h> using namespace std; struct squarePower { long long int I = 0, O = 0; long long int result() { return I*O; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int h, w; cin >> h >> w; char grid[h][w]; squarePower puissance[h][w]; for(int loop = 0; loop < h; ++loop) { for(int looping = 0; looping < w; ++looping) { cin >> grid[loop][looping]; } } for(int loop = 0; loop < w; ++loop) { int nbI = 0; for(int looping = h-1; looping >= 0; --looping) { if(grid[looping][loop] == 'I') { nbI++; } else if(grid[looping][loop] == 'J') { puissance[looping][loop].I = nbI; } } } for(int loop = 0; loop < h; ++loop) { int nbO = 0; for(int looping = w-1; looping >= 0; --looping) { if(grid[loop][looping] == 'O') { nbO++; } else if(grid[loop][looping] == 'J') { puissance[loop][looping].O = nbO; } } } long long int somme = 0; for(int loop = 0; loop < h; ++loop) { for(int looping = 0; looping < w; ++looping) { somme += puissance[loop][looping].result(); } } cout << somme; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...