Submission #771829

# Submission time Handle Problem Language Result Execution time Memory
771829 2023-07-03T10:00:34 Z RecursiveCo Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
480 ms 220748 KB
// CF template, version 3.0

#include <bits/stdc++.h>

using namespace std;

#define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0)
#define getTest int t; cin >> t
#define eachTest for (int _var=0;_var<t;_var++)
#define get(name) int (name); cin >> (name)
#define out(o) cout << (o)
#define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
#define sortl(name) sort((name).begin(), (name).end())
#define rev(name) reverse((name).begin(), (name).end())
#define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
#define decision(b) if (b){out("YES");}else{out("NO");}

#define int long long int

signed main() {
    improvePerformance;
    get(h);
    get(w);
    int p = 0;
    vector<vector<int>> grid(h, vector<int>(w));
    forto(h, i) {
        forto(w, j) {
            char c;
            cin >> c;
            if (c=='J') grid[i][j]=0;
            if (c=='O') grid[i][j]=1;
            if (c=='I') grid[i][j]=2;
        }
    }
    vector<vector<int>> sufo(h, vector<int>(w));
    vector<vector<int>> sufi(h, vector<int>(w));
    forto(h, i) {
        int tot = 0;
        for (int j = w - 1; j >= 0; j--) {
            tot += grid[i][j] == 1;
            sufo[i][j] = tot;
        }
    }
    forto(w, j) {
        int tot = 0;
        for (int i = h - 1; i >= 0; i--) {
            tot += grid[i][j] == 2;
            sufi[i][j] = tot;
        }
    }
    forto(h, i) {
        forto(w, j) {
            if (grid[i][j] == 0) p += sufo[i][j] * sufi[i][j];
        }
    }
    out(p);
}

Compilation message

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:10:23: warning: unnecessary parentheses in declaration of 'h' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
joi2019_ho_t1.cpp:22:5: note: in expansion of macro 'get'
   22 |     get(h);
      |     ^~~
joi2019_ho_t1.cpp:10:23: warning: unnecessary parentheses in declaration of 'w' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
joi2019_ho_t1.cpp:23:5: note: in expansion of macro 'get'
   23 |     get(w);
      |     ^~~
joi2019_ho_t1.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
joi2019_ho_t1.cpp:26:5: note: in expansion of macro 'forto'
   26 |     forto(h, i) {
      |     ^~~~~
joi2019_ho_t1.cpp:15:35: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
joi2019_ho_t1.cpp:27:9: note: in expansion of macro 'forto'
   27 |         forto(w, j) {
      |         ^~~~~
joi2019_ho_t1.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
joi2019_ho_t1.cpp:37:5: note: in expansion of macro 'forto'
   37 |     forto(h, i) {
      |     ^~~~~
joi2019_ho_t1.cpp:15:35: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
joi2019_ho_t1.cpp:44:5: note: in expansion of macro 'forto'
   44 |     forto(w, j) {
      |     ^~~~~
joi2019_ho_t1.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
joi2019_ho_t1.cpp:51:5: note: in expansion of macro 'forto'
   51 |     forto(h, i) {
      |     ^~~~~
joi2019_ho_t1.cpp:15:35: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
joi2019_ho_t1.cpp:52:9: note: in expansion of macro 'forto'
   52 |         forto(w, j) {
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 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 468 KB Output is correct
6 Correct 1 ms 488 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 468 KB Output is correct
6 Correct 1 ms 488 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 7 ms 4948 KB Output is correct
15 Correct 1 ms 452 KB Output is correct
16 Correct 4 ms 3412 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 9 ms 6480 KB Output is correct
19 Correct 6 ms 6228 KB Output is correct
20 Correct 9 ms 6356 KB Output is correct
21 Correct 9 ms 6468 KB Output is correct
22 Correct 6 ms 6224 KB Output is correct
23 Correct 6 ms 6356 KB Output is correct
24 Correct 9 ms 6476 KB Output is correct
25 Correct 6 ms 6172 KB Output is correct
26 Correct 6 ms 6356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 468 KB Output is correct
6 Correct 1 ms 488 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 7 ms 4948 KB Output is correct
15 Correct 1 ms 452 KB Output is correct
16 Correct 4 ms 3412 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 9 ms 6480 KB Output is correct
19 Correct 6 ms 6228 KB Output is correct
20 Correct 9 ms 6356 KB Output is correct
21 Correct 9 ms 6468 KB Output is correct
22 Correct 6 ms 6224 KB Output is correct
23 Correct 6 ms 6356 KB Output is correct
24 Correct 9 ms 6476 KB Output is correct
25 Correct 6 ms 6172 KB Output is correct
26 Correct 6 ms 6356 KB Output is correct
27 Correct 441 ms 208404 KB Output is correct
28 Correct 1 ms 1108 KB Output is correct
29 Correct 15 ms 16084 KB Output is correct
30 Correct 1 ms 852 KB Output is correct
31 Correct 325 ms 153504 KB Output is correct
32 Correct 398 ms 219468 KB Output is correct
33 Correct 370 ms 220104 KB Output is correct
34 Correct 389 ms 178016 KB Output is correct
35 Correct 426 ms 219276 KB Output is correct
36 Correct 371 ms 220104 KB Output is correct
37 Correct 480 ms 220748 KB Output is correct
38 Correct 276 ms 152396 KB Output is correct
39 Correct 253 ms 152788 KB Output is correct