Submission #877607

#TimeUsernameProblemLanguageResultExecution timeMemory
877607JakobZorzBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
181 ms89712 KiB
#include<iostream> #include<vector> #include<queue> #include<stack> #include<algorithm> #include<limits.h> #include<math.h> #include<map> #include<set> #include<unordered_map> #include<unordered_set> #include<iomanip> #include<cstring> typedef long long ll; typedef unsigned long long ull; typedef long double ld; using namespace std; const int MOD=1e9+7; //typedef pair<ll,ll>Point; //typedef pair<ll,ll>Line; //#define x first //#define y second int w,h; string arr[3000]; int numo[3000][3000]; int numi[3000][3000]; void solve(){ cin>>w>>h; for(int x=0;x<w;x++){ cin>>arr[x]; } for(int x=0;x<w;x++){ for(int y=h-1;y>=0;y--){ if(y!=h-1) numo[x][y]=numo[x][y+1]; if(arr[x][y]=='O') numo[x][y]++; } } for(int y=0;y<h;y++){ for(int x=w-1;x>=0;x--){ if(x!=w-1) numi[x][y]=numi[x+1][y]; if(arr[x][y]=='I') numi[x][y]++; } } ll res=0; for(int x=0;x<w;x++){ for(int y=0;y<h;y++){ if(arr[x][y]=='J'){ res+=(ll)numi[x][y]*numo[x][y]; //cout<<res<<"\n"; } } } cout<<res<<"\n"; } int main(){ ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL); //freopen("bank.in","r",stdin);freopen("bank.out","w",stdout); int t=1;//cin>>t; while(t--)solve(); return 0; } /* 4 4 JJOO JJOO IIJO IIIJ 3 4 JOIJ JIOO IIII */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...