Submission #261252

#TimeUsernameProblemLanguageResultExecution timeMemory
261252Valera_GrinenkoBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
282 ms89628 KiB
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
char a[3042][3042];
int orb[3042][3042] = {0}, ing[3042][3042] = {0};
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  ll ans = 0;

  int h, w;

  cin >> h >> w;

  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
      cin >> a[i][j];

  for(int i = h - 1; i >= 0; i--)
    for(int j = w - 1; j >= 0; j--) {
      orb[i][j] = orb[i][j + 1] + (a[i][j] == 'O');
      ing[i][j] = ing[i + 1][j] + (a[i][j] == 'I');
    }

  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
      if(a[i][j] == 'J')
        ans += 1ll * orb[i][j + 1] * ing[i + 1][j];

  cout << ans;

  return 0;
}
/*

*/

Compilation message (stderr)

joi2019_ho_t1.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("unroll-loops")
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...