Submission #1023635

#TimeUsernameProblemLanguageResultExecution timeMemory
1023635vjudge1Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
171 ms88560 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N = 3005;

int n, m;
char a[N][N];
ll c[N][N];

void sol() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      cin >> a[i][j];
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    ll cntO = 0;
    for (int j = m; j >= 1; --j) {
      if (a[i][j] == 'O') cntO++, c[i][j] = c[i-1][j];
      else if (a[i][j] == 'J') c[i][j] = c[i-1][j] + cntO;
      else ans += c[i-1][j], c[i][j] = c[i-1][j];
    }
  }
  cout << ans;
}

signed main() {
  cin.tie(0) -> sync_with_stdio(0);
  if (fopen("A.inp", "r")) freopen("A.inp", "r", stdin);
  int tc = 1; // cin >> tc;
  for (int test = 1; test <= tc; ++test) sol();
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:30:35: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   if (fopen("A.inp", "r")) freopen("A.inp", "r", stdin);
      |                            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...