제출 #1353294

#제출 시각아이디문제언어결과실행 시간메모리
1353294dex111222333444555Bitaro the Brave (JOI19_ho_t1)C++20
100 / 100
218 ms79840 KiB
#include <bits/stdc++.h>
#define all(v) begin(v), end(v)
#define ii pair<int, int>
#define fi first
#define se second
#define siz(v) (int)(v).size()
#define lli pair<long long, int>
#define dbg(x) "[" #x " = " << x << "]"
#define BIT(x, i) (((x) >> (i)) & 1)
#define MASK(i) (1LL << (i))
#define left __left
#define right __right

using namespace std;

bool M1;
const long long inf = 1e18 + 123;
const int mod = 1e9 + 7, infINT = 1e9 + 1321, LOG = 32;

template<class X, class Y> bool minimize(X &x, const Y &y){return x > y ? x = y, 1: 0;}
template<class X, class Y> bool maximize(X &x, const Y &y){return x < y ? x = y, 1: 0;}

mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
ll ran(ll l, ll r){
    return uniform_int_distribution<ll>(l, r)(rd);
}

void add(int &a, const int &b){
    a += b;
    if (a >= mod) a -= mod;
}

void sub(int &a, const int &b){
    a -= b;
    if (a < 0) a += mod;
}

int mul(const int &a, const int &b){
    return 1LL * a * 1LL * b % mod;
}

int bin_pow(int a, long long k){
    int res = 1;
    while(k){
        if (k & 1) res = mul(res, a);
        k >>= 1; a = mul(a, a);
    }
    return res;
}

const int MAXN = 3005, block = sqrt(MAXN);

int numRow, numCol, cntO[MAXN][MAXN], cntI[MAXN][MAXN];
char board[MAXN][MAXN];

void input(){
    cin >> numRow >> numCol;

    for(int i = 1; i <= numRow; i++)
    for(int j = 1; j <= numCol; j++) cin >> board[i][j];
}

void solve(){
    for(int i = 1; i <= numRow; i++){
        for(int j = numCol; j >= 1; j--){
            cntO[i][j] = cntO[i][j + 1];
            if (board[i][j] == 'O') cntO[i][j]++;
        }
    }

    for(int j = 1; j <= numCol; j++){
        for(int i = numRow; i >= 1; i--){
            cntI[i][j] = cntI[i + 1][j];
            if (board[i][j] == 'I') cntI[i][j]++;
        }
    }

    long long res = 0;
    for(int i = 1; i <= numRow; i++){
        for(int j = 1; j <= numCol; j++) if (board[i][j] == 'J') {
            res += 1LL * cntO[i][j] * 1LL * cntI[i][j];
        }
    }
    cout << res << '\n';
    cerr << res << '\n';
}

bool M2;
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define task "test"
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    input();
    solve();
    cerr << (&M2 - &M1) / 1048576 << " mb\n";
    cerr << (1.0 * clock()) / CLOCKS_PER_SEC << ".s\n";
}

컴파일 시 표준 에러 (stderr) 메시지

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:94:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   94 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:95:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   95 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...