Submission #139594

#TimeUsernameProblemLanguageResultExecution timeMemory
139594math0_0Bitaro the Brave (JOI19_ho_t1)C++11
100 / 100
750 ms115372 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pi; int main(){ int h, w; cin >> h >> w; string arr[h]; for(int one = 0; one < h; one++){ cin >> arr[one]; } int sufO[h][w] = {0}, sufI[h][w] = {0}; vector<pi> jpos; for(int one = h-1; one >= 0; --one){ for(int two = w-1; two >= 0; --two){ sufO[one][two] = 0; sufI[one][two] = 0; if(arr[one][two] == 'J'){ jpos.push_back(make_pair(one, two)); if(two != w-1){sufO[one][two] = sufO[one][two+1];} if(one != h-1){sufI[one][two] = sufI[one+1][two];} } else if(arr[one][two] == 'O'){ if(two == w-1){sufO[one][two] = 1;} else{sufO[one][two] = sufO[one][two+1] + 1;} if(one != h-1){sufI[one][two] = sufI[one+1][two];} }else{ if(one == h-1){sufI[one][two] = 1;} else{sufI[one][two] = sufI[one+1][two] + 1;} if(two != w-1){sufO[one][two] = sufO[one][two+1];} } } } ll ans = 0; for(int one = 0; one < jpos.size(); one++){ ll x = jpos[one].first; ll y = jpos[one].second; ll pwr = sufO[x][y+1]*sufI[x+1][y]; if(x==h-1 || y==w-1){pwr = 0;} ans+=pwr; } cout << ans; }

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:44:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int one = 0; one < jpos.size(); one++){
                   ~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...