| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1353294 | dex111222333444555 | Bitaro the Brave (JOI19_ho_t1) | C++20 | 218 ms | 79840 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";
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
