Submission #1038532

#TimeUsernameProblemLanguageResultExecution timeMemory
1038532MrPavlitoBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
216 ms220872 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define sc second #define endl "\n" #define pii pair<int,int> using namespace std; const int MAXN = 1e5+5; const int mod7 = 1e9+7; const long long inf = 1e18; signed main() { ios_base::sync_with_stdio(false),cin.tie(0), cout.tie(0); int tt=1; //cin >> tt; while(tt--) { int n,m; cin >> n >> m; vector<vector<int>> mat(n+1,vector<int>(m+1,0)); vector<vector<int>> prefh(n+1,vector<int>(m+1,0)); vector<vector<int>> prefv(n+1,vector<int>(m+1,0)); for(int i=1; i<=n; i++) { string s;cin >> s; for(int j=1; j<=m;j++) { mat[i][j] = s[j-1]; if(mat[i][j] == 'I')prefv[i][j] = 1; else if(mat[i][j] == 'O')prefh[i][j] = 1; } } for(int i=1; i<=n;i++)for(int j=1; j<=m; j++)prefh[i][j] += prefh[i][j-1]; for(int i=1; i<=m;i++)for(int j=1; j<=n; j++)prefv[j][i] += prefv[j-1][i]; long long rez = 0; for(int i=1; i<=n; i++) { for(int j=1; j<=m; j++) { if(mat[i][j] != 'J')continue; rez+= (prefh[i][m]-prefh[i][j])*(prefv[n][j]-prefv[i][j]); } } cout << rez << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...