답안 #1038631

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1038631 2024-07-30T03:58:39 Z khanhtb Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
230 ms 159240 KB
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC targt("avx2,bmi,bmi2,popcnt,lzcnt")
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define vi vector<ll>
#define vii vector<vi>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define all(a) a.begin(), a.end()
#define fi first
#define se second
using namespace std;
const ll mod = 998244353; 
const ll inf = 1e18;
const ll blocksz = 320;
const ll N = 3e3+8;
int n,m;
char a[N][N];
ll pre[N][N],suf[N][N];
void solve(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = m; j >= 1; j--){
            if(a[i][j] == 'O') pre[i][j]++;
            pre[i][j] += pre[i][j+1];
        }
    }
    for(int j = 1; j <= m; j++){
        for(int i = n; i >= 1; i--){
            if(a[i][j] == 'I') suf[i][j]++;
            suf[i][j] += suf[i+1][j];
        }
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(a[i][j] == 'J'){
                ans += pre[i][j]*suf[i][j];
            }
        }
    }
    cout << ans;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);   
    if (fopen("test.inp", "r")){
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
    ll T = 1;
    // cin >> T;
    for (ll i = 1; i <= T; i++){
        solve();
        cout << '\n';
    }
}

Compilation message

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:56:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:57:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |         freopen("test.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 408 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 1624 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 1 ms 1660 KB Output is correct
8 Correct 1 ms 1628 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 1 ms 1628 KB Output is correct
11 Correct 1 ms 1628 KB Output is correct
12 Correct 1 ms 1628 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 408 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 1624 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 1 ms 1660 KB Output is correct
8 Correct 1 ms 1628 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 1 ms 1628 KB Output is correct
11 Correct 1 ms 1628 KB Output is correct
12 Correct 1 ms 1628 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 7 ms 9048 KB Output is correct
15 Correct 2 ms 5468 KB Output is correct
16 Correct 4 ms 5468 KB Output is correct
17 Correct 0 ms 600 KB Output is correct
18 Correct 8 ms 10072 KB Output is correct
19 Correct 12 ms 10076 KB Output is correct
20 Correct 7 ms 10028 KB Output is correct
21 Correct 12 ms 10148 KB Output is correct
22 Correct 7 ms 10168 KB Output is correct
23 Correct 7 ms 9816 KB Output is correct
24 Correct 8 ms 10096 KB Output is correct
25 Correct 8 ms 10072 KB Output is correct
26 Correct 7 ms 9820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 408 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 1624 KB Output is correct
6 Correct 1 ms 1628 KB Output is correct
7 Correct 1 ms 1660 KB Output is correct
8 Correct 1 ms 1628 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 1 ms 1628 KB Output is correct
11 Correct 1 ms 1628 KB Output is correct
12 Correct 1 ms 1628 KB Output is correct
13 Correct 1 ms 1628 KB Output is correct
14 Correct 7 ms 9048 KB Output is correct
15 Correct 2 ms 5468 KB Output is correct
16 Correct 4 ms 5468 KB Output is correct
17 Correct 0 ms 600 KB Output is correct
18 Correct 8 ms 10072 KB Output is correct
19 Correct 12 ms 10076 KB Output is correct
20 Correct 7 ms 10028 KB Output is correct
21 Correct 12 ms 10148 KB Output is correct
22 Correct 7 ms 10168 KB Output is correct
23 Correct 7 ms 9816 KB Output is correct
24 Correct 8 ms 10096 KB Output is correct
25 Correct 8 ms 10072 KB Output is correct
26 Correct 7 ms 9820 KB Output is correct
27 Correct 214 ms 158804 KB Output is correct
28 Correct 12 ms 28248 KB Output is correct
29 Correct 14 ms 13916 KB Output is correct
30 Correct 1 ms 860 KB Output is correct
31 Correct 169 ms 131776 KB Output is correct
32 Correct 197 ms 159056 KB Output is correct
33 Correct 200 ms 158800 KB Output is correct
34 Correct 195 ms 152404 KB Output is correct
35 Correct 206 ms 159188 KB Output is correct
36 Correct 192 ms 158800 KB Output is correct
37 Correct 230 ms 159240 KB Output is correct
38 Correct 162 ms 131376 KB Output is correct
39 Correct 150 ms 130900 KB Output is correct