Submission #1071027

#TimeUsernameProblemLanguageResultExecution timeMemory
1071027sitablechairBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
201 ms88556 KiB
#include <bits/stdc++.h> #define ll long long #define ldb long double #define endl '\n' #define For(i,l,r) for(int i=l;i<=r;i++) #define ForD(i,r,l) for(int i=r;i>=l;i--) #define REP(i,l,r) For(i,l,r-1) #define PER(i,r,l) ForD(i,r-1,l) #define ff first #define ss second #define pb emplace_back #define all(x) x.begin(),x.end() #define All(x,n) x+1,x+1+n #define Alll(x,n) x,x+n #define sz(x) (signed)x.size() #define unq(x) x.resize(unique(all(x))-x.begin()) #define mpa make_pair #ifdef NCGM #include"debug.h" #else #define debug(...) "fr"; #endif using namespace std; const int N=3003; int pfX[N][N],pfY[N][N]; int n,m; ll ans=0; char c[N][N]; int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> m; For(i,1,n) For(j,1,m) cin >> c[i][j]; For(i,1,n) { For(j,1,m) { pfY[i][j]=pfY[i][j-1]; if (c[i][j]=='O') pfY[i][j]++; } } For(j,1,m) { For(i,1,n) { pfX[i][j]=pfX[i-1][j]; if (c[i][j]=='I') pfX[i][j]++; } } For(i,1,n) For(j,1,m) if (c[i][j]=='J') { ll num1=pfX[n][j]-pfX[i-1][j],num2=pfY[i][m]-pfY[i][j-1]; ans+=num1*num2; } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...