Submission #419666

# Submission time Handle Problem Language Result Execution time Memory
419666 2021-06-07T11:10:06 Z arayi Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
278 ms 160276 KB
//Arayi
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cassert>
#include <chrono>
#include <random>
#include <complex>

#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jigglypuff
#define ld long double
#define itn int
#define pir pair<int, int>
#define all(x) (x).begin(), (x).end()
#define str string
#define enl endl
#define en endl
#define cd complex<long double>
#define vcd vector<cd>
#define vii vector<int>
#define vlli vector<lli>
using namespace std;

lli gcd(lli a, lli b) { return (b == 0LL ? a : gcd(b, a % b)); }
ld dist(ld x, ld y1, ld x2, ld y2)
{
    return sqrt((x - x2) * (x - x2) + (y1 - y2) * (y1 - y2));
}
lli S(lli a)
{
    return (a * (a + 1LL)) / 2;
}
mt19937 rnd(363542);
char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 0, -1, 0, 1, -1, -1, 1, 1, 0 };
int dy[] = { -1, 0, 1, 0, -1, 1, -1, 1, 0 };


const int N = 1e6 + 30;
const lli mod = 1e9 - 1;
const ld pi = acos(-1);
const int T = 550;

lli bp(lli a, lli b = mod - 2LL)
{
    lli ret = 1;
    while (b)
    {
        if (b & 1) ret *= a, ret %= mod;
        a *= a;
        a %= mod;
        b >>= 1;
    }
    return ret;
}
ostream& operator<<(ostream& c, pir a)
{
    c << a.fr << " " << a.sc;
    return c;
}
template<class T>
void maxi(T& a, T b)
{
    a = max(a, b);
}
template <class T>
void mini(T& a, T b)
{
    a = min(a, b);
}


int n,m;
char a[3030][3030];
lli pr[3030][3030], sf[3030][3030], ans;
int main()
{
    fastio;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin >> a[i][j];
    for(int i = n - 1; i >= 0; i--)
    {
        for(int j = m - 1; j >= 0; j--)
        {
            pr[i][j] = pr[i][j + 1] + (a[i][j] == 'O');
            sf[i][j] = sf[i + 1][j] + (a[i][j] == 'I');
        }
    }
    for (int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            //cout << pr[i][j] <<" ";
            if(a[i][j] == 'J') ans += sf[i][j] * pr[i][j];
        }
        //cout << endl;
    }
    cout << ans << endl;
    return 0;
}

/*
5 4 4
1 2
3 1
3 4
5 3
4 5 2 3
2 1 3 1
1 3 5
2 3 4 5
2 1 3 1
    __
  *(><)*
    \/ /
    ||/
  --||
    ||
    /\
   /  \
  /    \

*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 1484 KB Output is correct
6 Correct 1 ms 1484 KB Output is correct
7 Correct 1 ms 1356 KB Output is correct
8 Correct 1 ms 1484 KB Output is correct
9 Correct 1 ms 1484 KB Output is correct
10 Correct 1 ms 1356 KB Output is correct
11 Correct 1 ms 1612 KB Output is correct
12 Correct 1 ms 1484 KB Output is correct
13 Correct 1 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 1484 KB Output is correct
6 Correct 1 ms 1484 KB Output is correct
7 Correct 1 ms 1356 KB Output is correct
8 Correct 1 ms 1484 KB Output is correct
9 Correct 1 ms 1484 KB Output is correct
10 Correct 1 ms 1356 KB Output is correct
11 Correct 1 ms 1612 KB Output is correct
12 Correct 1 ms 1484 KB Output is correct
13 Correct 1 ms 1356 KB Output is correct
14 Correct 9 ms 8908 KB Output is correct
15 Correct 3 ms 5068 KB Output is correct
16 Correct 6 ms 5324 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 11 ms 10000 KB Output is correct
19 Correct 11 ms 9796 KB Output is correct
20 Correct 11 ms 9804 KB Output is correct
21 Correct 11 ms 9932 KB Output is correct
22 Correct 10 ms 9804 KB Output is correct
23 Correct 10 ms 9804 KB Output is correct
24 Correct 11 ms 10024 KB Output is correct
25 Correct 11 ms 9804 KB Output is correct
26 Correct 12 ms 9812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 1484 KB Output is correct
6 Correct 1 ms 1484 KB Output is correct
7 Correct 1 ms 1356 KB Output is correct
8 Correct 1 ms 1484 KB Output is correct
9 Correct 1 ms 1484 KB Output is correct
10 Correct 1 ms 1356 KB Output is correct
11 Correct 1 ms 1612 KB Output is correct
12 Correct 1 ms 1484 KB Output is correct
13 Correct 1 ms 1356 KB Output is correct
14 Correct 9 ms 8908 KB Output is correct
15 Correct 3 ms 5068 KB Output is correct
16 Correct 6 ms 5324 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 11 ms 10000 KB Output is correct
19 Correct 11 ms 9796 KB Output is correct
20 Correct 11 ms 9804 KB Output is correct
21 Correct 11 ms 9932 KB Output is correct
22 Correct 10 ms 9804 KB Output is correct
23 Correct 10 ms 9804 KB Output is correct
24 Correct 11 ms 10024 KB Output is correct
25 Correct 11 ms 9804 KB Output is correct
26 Correct 12 ms 9812 KB Output is correct
27 Correct 278 ms 159820 KB Output is correct
28 Correct 15 ms 26316 KB Output is correct
29 Correct 19 ms 13944 KB Output is correct
30 Correct 1 ms 716 KB Output is correct
31 Correct 200 ms 131620 KB Output is correct
32 Correct 238 ms 160184 KB Output is correct
33 Correct 231 ms 159768 KB Output is correct
34 Correct 228 ms 152672 KB Output is correct
35 Correct 246 ms 160136 KB Output is correct
36 Correct 233 ms 159776 KB Output is correct
37 Correct 273 ms 160276 KB Output is correct
38 Correct 176 ms 130736 KB Output is correct
39 Correct 170 ms 131012 KB Output is correct