Submission #963695

#TimeUsernameProblemLanguageResultExecution timeMemory
963695MaaxleBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
248 ms206496 KiB
#include <bits/stdc++.h>

#define range(it, a, b) for (ll it = a; it < b; it++)
#define all(x) begin(x), end(x)
#define ll long long
#define ull unsigned long long
#define INF64 ((ll) 1 << 62)
#define INF32 (1 << 30)
#define mset multiset
#define uset unordered_set
#define umap unordered_map 
#define pqueue priority_queue 
#define ptr(A) shared_ptr<A>

using namespace std;

void setio (string name) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if (name.size()) {
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}

struct TPos {
    ll i, j;
};

ll h, w;
ll orb[3000][3000];
ll ingot[3000][3000];

void solve() {
    cin >> h >> w;

    vector<TPos> q;
    char x;
    range(i, 0, h) {
        range(j, 0, w) {
            cin >> x;
            orb[i][j] = (x == 'O');
            ingot[i][j] = (x == 'I');
            if (x == 'J')
                q.push_back({i, j});
            orb[i][j] += (j ? orb[i][j-1] : 0);
            ingot[i][j] += (i ? ingot[i-1][j] : 0);
        }
    }

    ll ans = 0;
    for (TPos& it : q) {
        ll o = orb[it.i][w-1] - orb[it.i][it.j];
        ll i = ingot[h-1][it.j] - ingot[it.i][it.j];
        ans += o*i;
    }
    cout << ans;
}

int main () {
    setio("");
    ll t = 1; 
    // cin >> t;
    while (t--) solve();
}

// IT'S TOUGH, I KNOW
// BUT YOU'D RATHER DIE FIGHTING THAN LIVE ON YOUR KNEES
// THOUG H YOU WON'T DO NEITHER OF THOSE
// IMPOSSIBLE, AS IT'S AGAINST YOUR NATURE
// AS YOU ALREADY WON
// I SEE YOUR MEDAL HANGING FROM YOUR NECK
// SHINING AS NOTHING YOU'VE EVER HAD

// THOUSANDS AND THOUSANDS OF LINES
// YOU AREADY MADE IT THIS FAR
// AND WHO COULD TELL HOW FAR YOU WILL GET...
// BUT YOU?

// THEN COME ON, YOU BASTARD!
// GO CLEAR YOUR MIND AND STAND
// AS EACH OF THOSE LINES IS A STEP CLOSER
// CLOSER TO THE GREATNESS YOU PURSUE
// CLOSER TO THE GREATNESS YOU ALREADY HAVE

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'void setio(std::string)':
joi2019_ho_t1.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen((name + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...