Submission #209194

#TimeUsernameProblemLanguageResultExecution timeMemory
209194ffaoBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
155 ms82340 KiB
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <memory.h>
#include <cmath>
#include <array>

void re(int& x);

void re(char* c);

void pr(long long x);

void pr(const char *x);

void ps();
template<class T, class... Ts> void ps(const T& t, const Ts&... ts);

#ifdef FFDBG

#else
#define dbg(x...) dsfdsfsdfasd
#endif

void re(int& x) { scanf("%d", &x); }

void re(char* c) { scanf("%s", c); }

void pr(long long x) { printf("%lld", x); }

void pr(const char *x) { printf("%s", x); }

void ps() { pr("\n"); }
template<class T, class... Ts> void ps(const T& t, const Ts&... ts) { 
    pr(t); if (sizeof...(ts)) pr(" "); ps(ts...); 
}

#define rep(i, a, b) for(int i = a; i < (b); ++i)

int r,c;
char board[3100][3100];
int orbs_right[3100][3100];
int ingots_below[3100][3100];

void solve()
{
    re(r); re(c);
    rep(i,0,r) re(board[i]);

    for (int i = r-1; i>= 0; i--) {
        for (int j = c-1; j >= 0; j--) {
            orbs_right[i][j] = (orbs_right[i][j+1] + (board[i][j] == 'O'));
            ingots_below[i][j] = (ingots_below[i+1][j] + (board[i][j] == 'I'));
        }
    }

    long long ans = 0;
    rep(i,0,r) rep(j,0,c) if (board[i][j] == 'J') ans += orbs_right[i][j] * ingots_below[i][j];
    ps(ans);
}

int main() {

    solve();
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'void re(int&)':
joi2019_ho_t1.cpp:30:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 void re(int& x) { scanf("%d", &x); }
                   ~~~~~^~~~~~~~~~
joi2019_ho_t1.cpp: In function 'void re(char*)':
joi2019_ho_t1.cpp:32:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 void re(char* c) { scanf("%s", c); }
                    ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...