Submission #680537

#TimeUsernameProblemLanguageResultExecution timeMemory
680537adilet_321Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
255 ms154772 KiB
#include <bits/stdc++.h> #include <vector> #include <map> #include <queue> #include <deque> #include <algorithm> #define ll long long #define FOR(i,a) for (long long i=0;i<a;i++) #define FORN(i,a) for (long long i=1;i<=a;i++) #define pb push_back #define mp make_pair #define ff first #define ss second using namespace std; /* ll bin1(ll a,ll b){ if (b==0)return 1; if (b==1)return a; if (b&1)return bin(a,b-1)*a; c=bin(a,b/2); return c*c; } ll bin2(ll a,ll b){ ll res=1; while(b){ if(b&1){ res*=a; } a*=a; b/=2; } return res; } */ vector <string> s; ll ans=0; ll a[3001][3001]; ll d[3003][3003]; void solve(){ ll n,m; cin>>n>>m; for(ll i=1;i<=n;i++){ string h; cin>>h; s.pb(h); } for(ll i=0;i<n;i++){ ll h=0; for(ll j=0;j<m;j++){ if (s[i][j]=='O'){ h++; } a[i][j]=h; } } for(int i=0;i<m;i++){ ll h=0; for (ll j=0;j<n;j++){ if (s[j][i]=='I'){ h++; } d[j][i]=h; } } for(ll i=0;i<n;i++){ for (ll j=0;j<m;j++){ if (s[i][j]=='J'){ ans+=((a[i][m-1]-a[i][j])*(d[n-1][j]-d[i][j])); } } } cout<<ans; } int main(){ //srand( time(0)); //rand() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); //freopen("sum.in", "r", stdin); //freopen("sum.out", "w", stdout); ll c=1; while(c--){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...