Submission #1023577

#TimeUsernameProblemLanguageResultExecution timeMemory
1023577danglayloi1Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
226 ms247632 KiB
#include <bits/stdc++.h> #define ii pair<int, int> #define fi first #define se second #define inf 0x3f3f3f3f3f3f3f3f using namespace std; using ll = long long; const ll mod=1e9+7; const int nx=3e3+5; int n, m, a[nx][nx], r[nx][nx][3], c[nx][nx][3]; ll ans=0; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m; for(int i = 1; i <= n; i++) { string s; cin>>s; for(int j = 1; j <= m; j++) { if(s[j-1]=='J') a[i][j]=0; else if(s[j-1]=='O') a[i][j]=1; else a[i][j]=2; for(int k = 0; k < 3; k++) { r[i][j][k]=r[i-1][j][k]+(a[i][j]==k); c[i][j][k]=c[i][j-1][k]+(a[i][j]==k); } } } for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { if(a[i][j]==0) ans+=(r[n][j][2]-r[i][j][2])*(c[i][m][1]-c[i][j][1]); } } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...