Submission #308250

#TimeUsernameProblemLanguageResultExecution timeMemory
308250Bill_00Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
572 ms186652 KiB
#include <bits/stdc++.h> #define pp push #define mp make_pair #define ff first #define ss second #define pb push_back typedef long long ll; using namespace std; char a[3005][3005]; ll dpi[3005][3005]; ll dpo[3005][3005]; vector<pair<int,int> >J; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int h,w; cin >> h >> w; for(int i=1;i<=h;i++){ for(int j=1;j<=w;j++){ cin >> a[i][j]; if(a[i][j]=='J'){ J.pb(mp(i,j)); } } } for(int i=1;i<=w;i++){ for(int j=h;j>=1;j--){ if(a[j][i]=='I'){ dpi[j][i]=dpi[j+1][i]+1; } else dpi[j][i]=dpi[j+1][i]; } } for(int i=1;i<=h;i++){ for(int j=w;j>=1;j--){ if(a[i][j]=='O'){ dpo[i][j]=dpo[i][j+1]+1; } else dpo[i][j]=dpo[i][j+1]; } } ll ans=0; for(int i=0;i<J.size();i++){ int x=J[i].ff; int y=J[i].ss; ans+=(dpo[x][y]*dpi[x][y]); } cout << ans; }

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:44:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  for(int i=0;i<J.size();i++){
      |              ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...