답안 #586466

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
586466 2022-06-30T10:02:29 Z Sharky Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
258 ms 10124 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
using vi = vector<int>;
using vb = vector<bool>;
using pi = pair<int, int>;

#define pb push_back
#define all(x) x.begin(), x.end()
#define FOR(i, a, b) for (int i = (int) a; i < (int) b; i++)
#define rep(i, n) for (int i = 0; i < (int) n; i++)
#define rep1(i, n) for (int i = 1; i <= (int) n; i++)
#define sz(x) (int) x.size()
#define fi first
#define se second
#define rd(a, sz) rep(i, n) cin >> a[i];
#define rd1(a, sz) rep1(i, n) cin >> a[i];

void __print(int x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << '}';}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ["; _print(__VA_ARGS__)
#else
#define debug(...)
#endif

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 1e9 + 7;
const int inf = 1e18;

void solve(int tc) {
    int n, m, ans = 0; cin >> n >> m;
    vector<vector<char>> a(n, vector<char> (m));
    vector<int> r(n, 0), c(m, 0);
    rep(i, n) rep(j, m) {
        cin >> a[i][j];
        if (a[i][j] == 'O') r[i]++;
        if (a[i][j] == 'I') c[j]++;
    }
    rep(i, n) rep(j, m) {
        if (a[i][j] == 'O') r[i]--;
        if (a[i][j] == 'I') c[j]--;
        if (a[i][j] == 'J') {
            ans += r[i] * c[j];
        }
    }
    cout << ans << "\n";
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int tt = 1; 
    // cin >> tt;
    rep1(i, tt) solve(i);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 6 ms 468 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 8 ms 468 KB Output is correct
19 Correct 6 ms 724 KB Output is correct
20 Correct 4 ms 716 KB Output is correct
21 Correct 9 ms 724 KB Output is correct
22 Correct 6 ms 724 KB Output is correct
23 Correct 5 ms 724 KB Output is correct
24 Correct 8 ms 832 KB Output is correct
25 Correct 6 ms 692 KB Output is correct
26 Correct 4 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 6 ms 468 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 3 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 8 ms 468 KB Output is correct
19 Correct 6 ms 724 KB Output is correct
20 Correct 4 ms 716 KB Output is correct
21 Correct 9 ms 724 KB Output is correct
22 Correct 6 ms 724 KB Output is correct
23 Correct 5 ms 724 KB Output is correct
24 Correct 8 ms 832 KB Output is correct
25 Correct 6 ms 692 KB Output is correct
26 Correct 4 ms 724 KB Output is correct
27 Correct 248 ms 9552 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 12 ms 1492 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 183 ms 7320 KB Output is correct
32 Correct 190 ms 10124 KB Output is correct
33 Correct 148 ms 9676 KB Output is correct
34 Correct 223 ms 7796 KB Output is correct
35 Correct 177 ms 9492 KB Output is correct
36 Correct 126 ms 9476 KB Output is correct
37 Correct 258 ms 9504 KB Output is correct
38 Correct 138 ms 6764 KB Output is correct
39 Correct 93 ms 6808 KB Output is correct