답안 #162373

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
162373 2019-11-07T19:29:49 Z godwind Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
471 ms 159224 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <random>
#include <ctime>
#include <utility>
#include <fstream>
#include <queue>
#include <deque>
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("vpt")
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/STACK:256000000")
#pragma warning(disable:4996)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
const ld pi = 3.14159265358979323846264;
const char el = '\n';
//const int inf = 1000'000'000;
const ll llinf = 1e18, mod = 1000'000'007;
 
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define firn(i, n) for (int i = 1; i < (int)n; ++i)
#define all(v) v.begin(), v.end()
#define x first
#define y second
 
template<typename T> bool uin(T &a, T b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T> bool uax(T &a, T b) { if (b > a) { a = b; return 1; } return 0; }
template<class iterator> void output(iterator begin, iterator end, char p = ' ', ostream &out = cout) { while (begin != end) { out << (*begin) << p; begin++; } out << el; }
template<class T> void output(T x, char p = ' ', ostream &out = cout) { output(all(x), p, out); }
 
mt19937 rnd(time(NULL));

#define int long long

const int N = 3005;

char a[N][N];
int O[N][N];
int I[N][N];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> a[i][j];
            if (a[i][j] == 'O') {
                O[i][j] = 1;
            }
            if (a[i][j] == 'I') {
                I[i][j] = 1;
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = m; j; --j) {
            O[i][j] = O[i][j] + O[i][j + 1];
        }
    }
    for (int j = 1; j <= m; ++j) {
        for (int i = n; i; --i) {
            I[i][j] = I[i][j] + I[i + 1][j];
        }
    }
    long long res = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (a[i][j] == 'J') {
                res += O[i][j] * I[i][j];
            }
        }
    }
    cout << res << '\n';
    return 0;
}
/*
<>>><<><<<<<>>><
0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 1
0 3 2 1 0 1 2 0 1 2 3 4 5 3 2 0 1 

*/

Compilation message

joi2019_ho_t1.cpp:24:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/STACK:256000000")
 
joi2019_ho_t1.cpp:25:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 1656 KB Output is correct
6 Correct 3 ms 1528 KB Output is correct
7 Correct 3 ms 1528 KB Output is correct
8 Correct 3 ms 1656 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 3 ms 1528 KB Output is correct
11 Correct 3 ms 1656 KB Output is correct
12 Correct 3 ms 1656 KB Output is correct
13 Correct 3 ms 1528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 1656 KB Output is correct
6 Correct 3 ms 1528 KB Output is correct
7 Correct 3 ms 1528 KB Output is correct
8 Correct 3 ms 1656 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 3 ms 1528 KB Output is correct
11 Correct 3 ms 1656 KB Output is correct
12 Correct 3 ms 1656 KB Output is correct
13 Correct 3 ms 1528 KB Output is correct
14 Correct 15 ms 9080 KB Output is correct
15 Correct 6 ms 5112 KB Output is correct
16 Correct 9 ms 5368 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 18 ms 10104 KB Output is correct
19 Correct 16 ms 9848 KB Output is correct
20 Correct 15 ms 9848 KB Output is correct
21 Correct 18 ms 10068 KB Output is correct
22 Correct 14 ms 9848 KB Output is correct
23 Correct 15 ms 9848 KB Output is correct
24 Correct 18 ms 9976 KB Output is correct
25 Correct 15 ms 9848 KB Output is correct
26 Correct 16 ms 9848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 1656 KB Output is correct
6 Correct 3 ms 1528 KB Output is correct
7 Correct 3 ms 1528 KB Output is correct
8 Correct 3 ms 1656 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 3 ms 1528 KB Output is correct
11 Correct 3 ms 1656 KB Output is correct
12 Correct 3 ms 1656 KB Output is correct
13 Correct 3 ms 1528 KB Output is correct
14 Correct 15 ms 9080 KB Output is correct
15 Correct 6 ms 5112 KB Output is correct
16 Correct 9 ms 5368 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 18 ms 10104 KB Output is correct
19 Correct 16 ms 9848 KB Output is correct
20 Correct 15 ms 9848 KB Output is correct
21 Correct 18 ms 10068 KB Output is correct
22 Correct 14 ms 9848 KB Output is correct
23 Correct 15 ms 9848 KB Output is correct
24 Correct 18 ms 9976 KB Output is correct
25 Correct 15 ms 9848 KB Output is correct
26 Correct 16 ms 9848 KB Output is correct
27 Correct 448 ms 158684 KB Output is correct
28 Correct 25 ms 26360 KB Output is correct
29 Correct 26 ms 13944 KB Output is correct
30 Correct 3 ms 888 KB Output is correct
31 Correct 334 ms 131660 KB Output is correct
32 Correct 387 ms 159088 KB Output is correct
33 Correct 372 ms 158588 KB Output is correct
34 Correct 397 ms 152568 KB Output is correct
35 Correct 389 ms 159104 KB Output is correct
36 Correct 372 ms 158684 KB Output is correct
37 Correct 471 ms 159224 KB Output is correct
38 Correct 272 ms 130808 KB Output is correct
39 Correct 280 ms 131064 KB Output is correct