답안 #219464

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
219464 2020-04-05T11:22:08 Z PeregudovSergey Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
278 ms 160120 KB
#include <bits/stdc++.h>

#define int long long

#define pii pair<int, int>

#define x1 x1228
#define y1 y1228

#define left left228
#define right right228

#define pb push_back
#define eb emplace_back

#define mp make_pair                                                                
                                                                                                                                        
#define ff first                                                                  
#define ss second   

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << endl; 
#define TIME (ld)clock()/CLOCKS_PER_SEC

using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 3000 + 7, mod = 1e9 + 7, MAXN = 1e6 + 7;
const double eps = 1e-9;
const ll inf = 1e18;
mt19937 rnd(time(0));
int h, w; 
string a[maxn];
int row[maxn][maxn]; 
int col[maxn][maxn]; 

void solve() {
    cin >> h >> w; 
    for (int i = 0; i < h; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) row[i][j + 1] = row[i][j] + (a[i][j] == 'O'); 
    }                                               
    for (int j = 0; j < w; ++j) {
        for (int i = 0; i < h; ++i) {
            col[j][i + 1] = col[j][i] + (a[i][j] == 'I');
        }
    }
    int ans = 0; 
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (a[i][j] == 'J') ans += (row[i][w] - row[i][j + 1]) * (col[j][h] - col[j][i + 1]);             
        }
    }
    cout << ans; 
}                                
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1; 
    for (int i = 0; i < t; ++i) {              
        solve();
    }
    return 0;
}  
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 6 ms 1400 KB Output is correct
6 Correct 5 ms 1280 KB Output is correct
7 Correct 6 ms 1408 KB Output is correct
8 Correct 5 ms 1408 KB Output is correct
9 Correct 5 ms 1280 KB Output is correct
10 Correct 5 ms 1408 KB Output is correct
11 Correct 5 ms 1408 KB Output is correct
12 Correct 5 ms 1280 KB Output is correct
13 Correct 6 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 6 ms 1400 KB Output is correct
6 Correct 5 ms 1280 KB Output is correct
7 Correct 6 ms 1408 KB Output is correct
8 Correct 5 ms 1408 KB Output is correct
9 Correct 5 ms 1280 KB Output is correct
10 Correct 5 ms 1408 KB Output is correct
11 Correct 5 ms 1408 KB Output is correct
12 Correct 5 ms 1280 KB Output is correct
13 Correct 6 ms 1408 KB Output is correct
14 Correct 10 ms 7424 KB Output is correct
15 Correct 6 ms 2304 KB Output is correct
16 Correct 10 ms 5760 KB Output is correct
17 Correct 6 ms 1792 KB Output is correct
18 Correct 12 ms 8960 KB Output is correct
19 Correct 10 ms 8576 KB Output is correct
20 Correct 11 ms 8704 KB Output is correct
21 Correct 12 ms 8832 KB Output is correct
22 Correct 11 ms 8576 KB Output is correct
23 Correct 11 ms 8832 KB Output is correct
24 Correct 12 ms 8832 KB Output is correct
25 Correct 13 ms 8576 KB Output is correct
26 Correct 11 ms 8832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 6 ms 1400 KB Output is correct
6 Correct 5 ms 1280 KB Output is correct
7 Correct 6 ms 1408 KB Output is correct
8 Correct 5 ms 1408 KB Output is correct
9 Correct 5 ms 1280 KB Output is correct
10 Correct 5 ms 1408 KB Output is correct
11 Correct 5 ms 1408 KB Output is correct
12 Correct 5 ms 1280 KB Output is correct
13 Correct 6 ms 1408 KB Output is correct
14 Correct 10 ms 7424 KB Output is correct
15 Correct 6 ms 2304 KB Output is correct
16 Correct 10 ms 5760 KB Output is correct
17 Correct 6 ms 1792 KB Output is correct
18 Correct 12 ms 8960 KB Output is correct
19 Correct 10 ms 8576 KB Output is correct
20 Correct 11 ms 8704 KB Output is correct
21 Correct 12 ms 8832 KB Output is correct
22 Correct 11 ms 8576 KB Output is correct
23 Correct 11 ms 8832 KB Output is correct
24 Correct 12 ms 8832 KB Output is correct
25 Correct 13 ms 8576 KB Output is correct
26 Correct 11 ms 8832 KB Output is correct
27 Correct 252 ms 155128 KB Output is correct
28 Correct 13 ms 10240 KB Output is correct
29 Correct 24 ms 23040 KB Output is correct
30 Correct 11 ms 10112 KB Output is correct
31 Correct 205 ms 130892 KB Output is correct
32 Correct 211 ms 159520 KB Output is correct
33 Correct 251 ms 159892 KB Output is correct
34 Correct 215 ms 142328 KB Output is correct
35 Correct 250 ms 159608 KB Output is correct
36 Correct 244 ms 159864 KB Output is correct
37 Correct 278 ms 160120 KB Output is correct
38 Correct 142 ms 130040 KB Output is correct
39 Correct 170 ms 130428 KB Output is correct