Submission #716293

#TimeUsernameProblemLanguageResultExecution timeMemory
716293Urvuk3Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
350 ms150572 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int INF=1e9,MOD=1e9+7; const ll LINF=1e18; #define fi first #define se second #define pii pair<int,int> #define mid ((l+r)/2) #define sz(a) (int((a).size())) #define all(a) a.begin(),a.end() #define endl "\n" #define pb push_back void PRINT(int x) {cerr << x;} void PRINT(ll x) {cerr << x;} void PRINT(double x) {cerr << x;} void PRINT(char x) {cerr << '\'' << x << '\'';} void PRINT(string x) {cerr << '\"' << x << '\"';} void PRINT(bool x) {cerr << (x ? "true" : "false");} template<typename T,typename V> void PRINT(pair<T,V>& x){ cerr<<"{"; PRINT(x.fi); cerr<<","; PRINT(x.se); cerr<<"}"; } template<typename T> void PRINT(T &x){ int id=0; cerr<<"{"; for(auto _i:x){ cerr<<(id++ ? "," : ""); PRINT(_i); } cerr<<"}"; } void _PRINT(){ cerr<<"]\n"; } template<typename Head,typename... Tail> void _PRINT(Head h,Tail... t){ PRINT(h); if(sizeof...(t)) cerr<<", "; _PRINT(t...); } #define Debug(x...) cerr<<"["<<#x<<"]=["; _PRINT(x) void Solve(){ int N,M; cin>>N>>M; vector<vector<char>> a(N+1,vector<char>(M+1)); for(int i=1;i<=N;i++){ for(int j=1;j<=M;j++){ cin>>a[i][j]; } } vector<vector<ll>> prefO(N+1,vector<ll>(M+1,0)),prefI(N+1,vector<ll>(M+1,0)); for(int i=1;i<=N;i++){ for(int j=1;j<=M;j++){ prefO[i][j]=prefO[i][j-1]+(a[i][j]=='O'); } } for(int j=1;j<=M;j++){ for(int i=1;i<=N;i++){ prefI[i][j]=prefI[i-1][j]+(a[i][j]=='I'); } } ll res=0; for(int i=1;i<=N;i++){ for(int j=1;j<=M;j++){ if(a[i][j]=='J'){ res+=(prefO[i][M]-prefO[i][j-1])*(prefI[N][j]-prefI[i-1][j]); } } } cout<<res<<endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; 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...