Submission #825565

# Submission time Handle Problem Language Result Execution time Memory
825565 2023-08-15T03:29:09 Z dijbkr Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
365 ms 229596 KB
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll n,m;
char a[3002][3002];
ll jewel[3002][3002];
ll orb[3002][3002];
ll ingot[3002][3002];

int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL); cout.tie(NULL);
   cin >> n >> m;
   for (ll i=1; i<=n; i++) {
      for (ll j=1; j<=m; j++) {
         cin >> a[i][j];
      }
   }
   memset(jewel,0,sizeof(jewel));
   memset(orb,0,sizeof(orb));
   memset(ingot,0,sizeof(ingot));
   //cout << "jewel: " << jewel[1][5] << endl;
   for (ll i=1; i<=n; i++) {
      for (ll j=m; j>=1; j--) {
         if (a[i][j]=='J') {
            //cout << i << " " << j << endl;
            jewel[i][j]=jewel[i][j+1]+1;
         } else {
            jewel[i][j]=jewel[i][j+1];
         }
      }
   }
   for (ll i=1; i<=n; i++) {
      for (ll j=m; j>=1; j--) {
         if (a[i][j]=='O') {
            orb[i][j]=orb[i][j+1]+1;
         } else {
            orb[i][j]=orb[i][j+1];
         }
      }
   }
   for (ll j=1; j<=m; j++) {
      for (ll i=n; i>=1; i--) {
         if (a[i][j]=='I') {
            ingot[i][j]=ingot[i+1][j]+1;
         } else {
            ingot[i][j]=ingot[i+1][j];
         }
      }
   }
//   for (ll i=1; i<=n; i++) {
//      for (ll j=1; j<=m; j++) {
//         cout << jewel[i][j] << " ";
//      }
//      cout << endl;
//   }
//   cout << endl;
//   for (ll i=1; i<=n; i++) {
//      for (ll j=1; j<=m; j++) {
//         cout << orb[i][j] << " ";
//      }
//      cout << endl;
//   }
//   cout << endl;
//   for (ll i=1; i<=n; i++) {
//      for (ll j=1; j<=m; j++) {
//         cout << ingot[i][j] << " ";
//      }
//      cout << endl;
//   }
//   cout << endl;
//   //cout << orb[2][2] << " " << ingot[3][1];
   ll ans=0;
   for (ll i=1; i<=n; i++) {
      for (ll j=1; j<=m; j++) {
         if (a[i][j]=='J') {
//            cout << i << " " << j << endl;
//            cout << orb[i][j+1] << " " << ingot[i+1][j] << endl;
//            cout << endl;
            ans+=(orb[i][j+1]*ingot[i+1][j]);
         }
      }
   }
   cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 71 ms 211912 KB Output is correct
2 Correct 68 ms 211864 KB Output is correct
3 Correct 68 ms 211916 KB Output is correct
4 Correct 66 ms 211928 KB Output is correct
5 Correct 69 ms 212196 KB Output is correct
6 Correct 68 ms 212108 KB Output is correct
7 Correct 68 ms 212136 KB Output is correct
8 Correct 71 ms 212116 KB Output is correct
9 Correct 67 ms 212188 KB Output is correct
10 Correct 67 ms 212120 KB Output is correct
11 Correct 67 ms 212208 KB Output is correct
12 Correct 70 ms 212220 KB Output is correct
13 Correct 67 ms 212152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 211912 KB Output is correct
2 Correct 68 ms 211864 KB Output is correct
3 Correct 68 ms 211916 KB Output is correct
4 Correct 66 ms 211928 KB Output is correct
5 Correct 69 ms 212196 KB Output is correct
6 Correct 68 ms 212108 KB Output is correct
7 Correct 68 ms 212136 KB Output is correct
8 Correct 71 ms 212116 KB Output is correct
9 Correct 67 ms 212188 KB Output is correct
10 Correct 67 ms 212120 KB Output is correct
11 Correct 67 ms 212208 KB Output is correct
12 Correct 70 ms 212220 KB Output is correct
13 Correct 67 ms 212152 KB Output is correct
14 Correct 70 ms 213368 KB Output is correct
15 Correct 68 ms 213120 KB Output is correct
16 Correct 79 ms 212672 KB Output is correct
17 Correct 68 ms 211916 KB Output is correct
18 Correct 75 ms 213336 KB Output is correct
19 Correct 71 ms 213320 KB Output is correct
20 Correct 72 ms 213312 KB Output is correct
21 Correct 73 ms 213600 KB Output is correct
22 Correct 71 ms 213636 KB Output is correct
23 Correct 74 ms 213588 KB Output is correct
24 Correct 73 ms 213548 KB Output is correct
25 Correct 75 ms 213636 KB Output is correct
26 Correct 72 ms 213532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 211912 KB Output is correct
2 Correct 68 ms 211864 KB Output is correct
3 Correct 68 ms 211916 KB Output is correct
4 Correct 66 ms 211928 KB Output is correct
5 Correct 69 ms 212196 KB Output is correct
6 Correct 68 ms 212108 KB Output is correct
7 Correct 68 ms 212136 KB Output is correct
8 Correct 71 ms 212116 KB Output is correct
9 Correct 67 ms 212188 KB Output is correct
10 Correct 67 ms 212120 KB Output is correct
11 Correct 67 ms 212208 KB Output is correct
12 Correct 70 ms 212220 KB Output is correct
13 Correct 67 ms 212152 KB Output is correct
14 Correct 70 ms 213368 KB Output is correct
15 Correct 68 ms 213120 KB Output is correct
16 Correct 79 ms 212672 KB Output is correct
17 Correct 68 ms 211916 KB Output is correct
18 Correct 75 ms 213336 KB Output is correct
19 Correct 71 ms 213320 KB Output is correct
20 Correct 72 ms 213312 KB Output is correct
21 Correct 73 ms 213600 KB Output is correct
22 Correct 71 ms 213636 KB Output is correct
23 Correct 74 ms 213588 KB Output is correct
24 Correct 73 ms 213548 KB Output is correct
25 Correct 75 ms 213636 KB Output is correct
26 Correct 72 ms 213532 KB Output is correct
27 Correct 333 ms 229056 KB Output is correct
28 Correct 70 ms 218700 KB Output is correct
29 Correct 79 ms 213340 KB Output is correct
30 Correct 67 ms 211988 KB Output is correct
31 Correct 258 ms 225392 KB Output is correct
32 Correct 332 ms 229596 KB Output is correct
33 Correct 328 ms 229396 KB Output is correct
34 Correct 284 ms 227548 KB Output is correct
35 Correct 318 ms 229404 KB Output is correct
36 Correct 320 ms 229492 KB Output is correct
37 Correct 365 ms 229448 KB Output is correct
38 Correct 242 ms 225228 KB Output is correct
39 Correct 250 ms 225336 KB Output is correct