답안 #168604

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
168604 2019-12-14T08:25:15 Z srvlt Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
618 ms 220832 KB
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree <pair <ll, int>, null_type, less <pair <ll, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define db double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define endl "\n"

#define left fsdsdfoisf
#define sum dpsdfioppsf
#define assign xcvjlkdjfio
#define trie fksdfkjkfnjuiv
#define next sidlfjsfkl
#define merge sdfksdkfsldf

#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 3003;
int n, m, a[N][N], b[N][N], c[N][N];

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++) {
            if (s[j] == 'O') {
                a[i][j + 1] = 1;
            }   else if (s[j] == 'I') {
                a[i][j + 1] = 2;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            b[i][j] = b[i][j - 1] + (a[i][j] == 1);
        }
    }
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            c[j][i] = c[j - 1][i] + (a[j][i] == 2);
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (a[i][j] != 0) {
                continue;
            }
            ans += (b[i][m] - b[i][j]) * (c[n][j] - c[i][j]);
        }
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("meetings.in", "r", stdin);
//    freopen("meetings.out", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 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 1784 KB Output is correct
6 Correct 3 ms 1784 KB Output is correct
7 Correct 3 ms 1656 KB Output is correct
8 Correct 3 ms 1808 KB Output is correct
9 Correct 3 ms 1784 KB Output is correct
10 Correct 3 ms 1656 KB Output is correct
11 Correct 3 ms 1784 KB Output is correct
12 Correct 3 ms 1784 KB Output is correct
13 Correct 3 ms 1656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 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 1784 KB Output is correct
6 Correct 3 ms 1784 KB Output is correct
7 Correct 3 ms 1656 KB Output is correct
8 Correct 3 ms 1808 KB Output is correct
9 Correct 3 ms 1784 KB Output is correct
10 Correct 3 ms 1656 KB Output is correct
11 Correct 3 ms 1784 KB Output is correct
12 Correct 3 ms 1784 KB Output is correct
13 Correct 3 ms 1656 KB Output is correct
14 Correct 15 ms 11128 KB Output is correct
15 Correct 7 ms 5624 KB Output is correct
16 Correct 8 ms 6392 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 17 ms 12536 KB Output is correct
19 Correct 14 ms 12152 KB Output is correct
20 Correct 14 ms 11768 KB Output is correct
21 Correct 17 ms 12536 KB Output is correct
22 Correct 15 ms 12024 KB Output is correct
23 Correct 15 ms 11772 KB Output is correct
24 Correct 18 ms 12536 KB Output is correct
25 Correct 14 ms 12152 KB Output is correct
26 Correct 15 ms 11768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 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 1784 KB Output is correct
6 Correct 3 ms 1784 KB Output is correct
7 Correct 3 ms 1656 KB Output is correct
8 Correct 3 ms 1808 KB Output is correct
9 Correct 3 ms 1784 KB Output is correct
10 Correct 3 ms 1656 KB Output is correct
11 Correct 3 ms 1784 KB Output is correct
12 Correct 3 ms 1784 KB Output is correct
13 Correct 3 ms 1656 KB Output is correct
14 Correct 15 ms 11128 KB Output is correct
15 Correct 7 ms 5624 KB Output is correct
16 Correct 8 ms 6392 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 17 ms 12536 KB Output is correct
19 Correct 14 ms 12152 KB Output is correct
20 Correct 14 ms 11768 KB Output is correct
21 Correct 17 ms 12536 KB Output is correct
22 Correct 15 ms 12024 KB Output is correct
23 Correct 15 ms 11772 KB Output is correct
24 Correct 18 ms 12536 KB Output is correct
25 Correct 14 ms 12152 KB Output is correct
26 Correct 15 ms 11768 KB Output is correct
27 Correct 585 ms 220320 KB Output is correct
28 Correct 29 ms 29052 KB Output is correct
29 Correct 22 ms 17656 KB Output is correct
30 Correct 3 ms 1016 KB Output is correct
31 Correct 468 ms 182812 KB Output is correct
32 Correct 527 ms 218360 KB Output is correct
33 Correct 514 ms 206992 KB Output is correct
34 Correct 525 ms 212156 KB Output is correct
35 Correct 522 ms 212808 KB Output is correct
36 Correct 514 ms 207048 KB Output is correct
37 Correct 618 ms 220832 KB Output is correct
38 Correct 402 ms 179516 KB Output is correct
39 Correct 375 ms 169480 KB Output is correct