Submission #1148231

#TimeUsernameProblemLanguageResultExecution timeMemory
1148231why1Bitaro the Brave (JOI19_ho_t1)C++20
100 / 100
308 ms150240 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define pii pair<int,int> #define sz size() #define all(v) v.begin(),v.end() #define fi first #define se second const int N = 5e5; const int mod = 1e9+7; const ll INF = 1e18; const int di[] = {1, -1, 0, 0}; const int dj[] = {0, 0, 1, -1}; void solve() { int n,m; cin>>n>>m; char a[n+1][m+1]; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cin>>a[i][j]; } } ll cnt_o[n+1][m+1],cnt_i[n+1][m+1]; memset(cnt_o,0,sizeof(cnt_o)); memset(cnt_i,0,sizeof(cnt_i)); for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cnt_o[i][j]=cnt_o[i][j-1]+(a[i][j]=='O'); } } for(int i = 1; i <= m; i++){ for(int j = 1; j <= n; j++){ cnt_i[j][i]=cnt_i[j-1][i]+(a[j][i]=='I'); } } ll ans=0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(a[i][j]=='J'){ ll x=cnt_o[i][m]-cnt_o[i][j-1]; ll y=cnt_i[n][j]-cnt_i[i-1][j]; ans+=x*y; } } } cout<<ans<<"\n"; } int main() { //freopen("cowrun.in","r",stdin); //freopen("cowrun.out","w",stdout); ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t=1; //cin>>t; while(t--) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...