답안 #1070873

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1070873 2024-08-22T20:16:59 Z dosts Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
105 ms 18000 KB
//Dost SEFEROĞLU
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<    
#define all(cont) cont.begin(),cont.end()
#define vi vector<int>
const int MOD = 1e9+7,inf = 2e18;
const int N = 1e5+50;

void solve() { 
    int n,m;
    cin >> n >> m;
    char grid[n+1][m+1];
    for (int i=1;i<=n;i++) {
        string s;
        cin >> s;
        for (int j=1;j<=m;j++) grid[i][j] = s[j-1]; 
    }
    int ans = 0;
    vi stuff(m+1,0);
    for (int i=n;i>=1;i--) {
        for (int j=1;j<=m;j++) {
            if (grid[i][j] == 'I') stuff[j]++;
        }
        int os = 0;
        for (int j=m;j>=1;j--) {
            if (grid[i][j] == 'O') os++;
            else if (grid[i][j] == 'J') ans+=os*stuff[j];
        }
    }
    cout << ans << endl;
}
 
signed main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef Dodi
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    int t = 1;
    //cin >> t; 
    while (t --> 0) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 3 ms 856 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 2 ms 860 KB Output is correct
21 Correct 3 ms 720 KB Output is correct
22 Correct 1 ms 924 KB Output is correct
23 Correct 2 ms 860 KB Output is correct
24 Correct 4 ms 804 KB Output is correct
25 Correct 2 ms 912 KB Output is correct
26 Correct 1 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 3 ms 856 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 2 ms 860 KB Output is correct
21 Correct 3 ms 720 KB Output is correct
22 Correct 1 ms 924 KB Output is correct
23 Correct 2 ms 860 KB Output is correct
24 Correct 4 ms 804 KB Output is correct
25 Correct 2 ms 912 KB Output is correct
26 Correct 1 ms 860 KB Output is correct
27 Correct 105 ms 17252 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 3 ms 1624 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 67 ms 12608 KB Output is correct
32 Correct 39 ms 17748 KB Output is correct
33 Correct 33 ms 17860 KB Output is correct
34 Correct 79 ms 14676 KB Output is correct
35 Correct 33 ms 17744 KB Output is correct
36 Correct 28 ms 18000 KB Output is correct
37 Correct 88 ms 17996 KB Output is correct
38 Correct 21 ms 12624 KB Output is correct
39 Correct 20 ms 12628 KB Output is correct