Submission #239124

#TimeUsernameProblemLanguageResultExecution timeMemory
239124aggu_01000101Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
362 ms158968 KiB
#include <bits/stdc++.h> #define int long long #define INF 1000000000000000 #define lchild(i) (i*2 + 1) #define rchild(i) (i*2 + 2) #define mid(l, u) ((l+u)/2) #define x(p) p.first #define y(p) p.second #define MOD 998244353 using namespace std; signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int h, w; cin>>h>>w; char mat[h+1][w+1]; int preo[h+1][w+1]; int prer[h+1][w+1]; for(int i = 1;i<=h;i++) for(int j = 1;j<=w;j++) preo[i][j] = prer[i][j] = 0; for(int i = 1;i<=h;i++){ string s; cin>>s; for(int j = 1;j<=w;j++){ mat[i][j] = s[j-1]; } } int cnt = 0; for(int i = 1;i<=h;i++){ preo[i][w] = (mat[i][w]=='O'); for(int j = w-1;j>=1;j--){ preo[i][j] = preo[i][j+1] + (mat[i][j]=='O'); } } for(int j = 1;j<=w;j++){ prer[h][j] = (mat[h][j] == 'I'); for(int i = h-1;i>=1;i--){ prer[i][j] = prer[i+1][j] + (mat[i][j]=='I'); } } for(int i = 1;i<h;i++){ for(int j = 1;j<w;j++){ if(mat[i][j] == 'J') cnt += (preo[i][j+1] * prer[i+1][j]); } } cout<<cnt<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...