Submission #411786

# Submission time Handle Problem Language Result Execution time Memory
411786 2021-05-26T00:29:19 Z kimbj0709 Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
456 ms 218240 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define maxn 3050
int pref1[maxn][maxn];
int pref2[maxn][maxn];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int n,m;
  cin >> n >> m;
  memset(pref1,0,sizeof(pref1));
  memset(pref2,0,sizeof(pref2));
  char input;
  vector<pair<int,int> > pos;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> input;
      if(input=='I'){
        pref2[i][j] = 1;
      }
      else if(input=='J'){
        pos.push_back({i,j});
      }
      else if(input=='O'){
        pref1[i][j] = 1;
      }
    }
  }
  for(int i=0;i<maxn;i++){
    for(int j=maxn-2;j>=0;j--){
      pref1[i][j] += pref1[i][j+1];
      pref2[j][i] += pref2[j+1][i];
    }
  }
  int ans = 0;
  for(int i=0;i<pos.size();i++){
    ans += pref1[pos[i].f][pos[i].s]*pref2[pos[i].f][pos[i].s];
    //cout << pos[i].f << " " << pos[i].s << " " << pref1[pos[i].f][pos[i].s]*pref2[pos[i].f][pos[i].s] << "\n";
  }
  cout << ans;
}

Compilation message

joi2019_ho_t1.cpp: In function 'int32_t main()':
joi2019_ho_t1.cpp:39:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   for(int i=0;i<pos.size();i++){
      |               ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 153 ms 145860 KB Output is correct
2 Correct 177 ms 145912 KB Output is correct
3 Correct 172 ms 145944 KB Output is correct
4 Correct 172 ms 145884 KB Output is correct
5 Correct 151 ms 145988 KB Output is correct
6 Correct 151 ms 145964 KB Output is correct
7 Correct 154 ms 146068 KB Output is correct
8 Correct 155 ms 145996 KB Output is correct
9 Correct 154 ms 145988 KB Output is correct
10 Correct 163 ms 146152 KB Output is correct
11 Correct 153 ms 145988 KB Output is correct
12 Correct 156 ms 145988 KB Output is correct
13 Correct 159 ms 145976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 153 ms 145860 KB Output is correct
2 Correct 177 ms 145912 KB Output is correct
3 Correct 172 ms 145944 KB Output is correct
4 Correct 172 ms 145884 KB Output is correct
5 Correct 151 ms 145988 KB Output is correct
6 Correct 151 ms 145964 KB Output is correct
7 Correct 154 ms 146068 KB Output is correct
8 Correct 155 ms 145996 KB Output is correct
9 Correct 154 ms 145988 KB Output is correct
10 Correct 163 ms 146152 KB Output is correct
11 Correct 153 ms 145988 KB Output is correct
12 Correct 156 ms 145988 KB Output is correct
13 Correct 159 ms 145976 KB Output is correct
14 Correct 165 ms 147292 KB Output is correct
15 Correct 158 ms 145944 KB Output is correct
16 Correct 156 ms 147140 KB Output is correct
17 Correct 151 ms 145892 KB Output is correct
18 Correct 165 ms 148332 KB Output is correct
19 Correct 183 ms 146760 KB Output is correct
20 Correct 158 ms 148372 KB Output is correct
21 Correct 165 ms 148292 KB Output is correct
22 Correct 159 ms 148288 KB Output is correct
23 Correct 160 ms 148264 KB Output is correct
24 Correct 179 ms 148320 KB Output is correct
25 Correct 178 ms 146764 KB Output is correct
26 Correct 164 ms 148368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 153 ms 145860 KB Output is correct
2 Correct 177 ms 145912 KB Output is correct
3 Correct 172 ms 145944 KB Output is correct
4 Correct 172 ms 145884 KB Output is correct
5 Correct 151 ms 145988 KB Output is correct
6 Correct 151 ms 145964 KB Output is correct
7 Correct 154 ms 146068 KB Output is correct
8 Correct 155 ms 145996 KB Output is correct
9 Correct 154 ms 145988 KB Output is correct
10 Correct 163 ms 146152 KB Output is correct
11 Correct 153 ms 145988 KB Output is correct
12 Correct 156 ms 145988 KB Output is correct
13 Correct 159 ms 145976 KB Output is correct
14 Correct 165 ms 147292 KB Output is correct
15 Correct 158 ms 145944 KB Output is correct
16 Correct 156 ms 147140 KB Output is correct
17 Correct 151 ms 145892 KB Output is correct
18 Correct 165 ms 148332 KB Output is correct
19 Correct 183 ms 146760 KB Output is correct
20 Correct 158 ms 148372 KB Output is correct
21 Correct 165 ms 148292 KB Output is correct
22 Correct 159 ms 148288 KB Output is correct
23 Correct 160 ms 148264 KB Output is correct
24 Correct 179 ms 148320 KB Output is correct
25 Correct 178 ms 146764 KB Output is correct
26 Correct 164 ms 148368 KB Output is correct
27 Correct 456 ms 218020 KB Output is correct
28 Correct 157 ms 146244 KB Output is correct
29 Correct 173 ms 150716 KB Output is correct
30 Correct 156 ms 146080 KB Output is correct
31 Correct 359 ms 184512 KB Output is correct
32 Correct 372 ms 168208 KB Output is correct
33 Correct 364 ms 216060 KB Output is correct
34 Correct 402 ms 218092 KB Output is correct
35 Correct 407 ms 218240 KB Output is correct
36 Correct 361 ms 216060 KB Output is correct
37 Correct 448 ms 217048 KB Output is correct
38 Correct 299 ms 167592 KB Output is correct
39 Correct 316 ms 184580 KB Output is correct