Submission #259066

# Submission time Handle Problem Language Result Execution time Memory
259066 2020-08-07T06:39:20 Z Fidisk Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
229 ms 184056 KB
#include <bits/stdc++.h>
using namespace std;

#define oo 1e9
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)
#define _cos(xxxx) cos(xxxx*acos(-1)/180)
#define _sin(xxxx) sin(xxxx*acos(-1)/180)
#define _tan(xxxx) tan(xxxx*acos(-1)/180)
#define PE cout<<fixed

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;

const ld pi=acos(-1);

string s[5009];
ll n,m,i,j,f1[5009][5009],f2[5009][5009],res;

int main(){
    IO;
    cin>>n>>m;
    for (i=1;i<=n;i++) {
        cin>>s[i];
    } 
    for (i=1;i<=n;i++) {
        for (j=m;j>=1;j--) {
            if (s[i][j-1]=='O') {
                f1[i][j]=f1[i][j+1]+1;
            }
            else {
                f1[i][j]=f1[i][j+1];
            }
        }
    }
    for (i=n;i>=1;i--) {
        for (j=1;j<=m;j++) {
            if (s[i][j-1]=='I') {
                f2[i][j]=f2[i+1][j]+1;
            }
            else {
                f2[i][j]=f2[i+1][j];
            }
        }
    }
    for (i=1;i<=n;i++) {
        for (j=1;j<=m;j++) {
            if (s[i][j-1]=='J') {
                res+=f1[i][j]*f2[i][j];
            }
        }
    }
    cout<<res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 544 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 640 KB Output is correct
5 Correct 2 ms 1536 KB Output is correct
6 Correct 2 ms 1408 KB Output is correct
7 Correct 2 ms 1408 KB Output is correct
8 Correct 1 ms 1536 KB Output is correct
9 Correct 1 ms 1408 KB Output is correct
10 Correct 1 ms 1408 KB Output is correct
11 Correct 2 ms 1536 KB Output is correct
12 Correct 1 ms 1408 KB Output is correct
13 Correct 1 ms 1408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 544 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 640 KB Output is correct
5 Correct 2 ms 1536 KB Output is correct
6 Correct 2 ms 1408 KB Output is correct
7 Correct 2 ms 1408 KB Output is correct
8 Correct 1 ms 1536 KB Output is correct
9 Correct 1 ms 1408 KB Output is correct
10 Correct 1 ms 1408 KB Output is correct
11 Correct 2 ms 1536 KB Output is correct
12 Correct 1 ms 1408 KB Output is correct
13 Correct 1 ms 1408 KB Output is correct
14 Correct 8 ms 7936 KB Output is correct
15 Correct 3 ms 3968 KB Output is correct
16 Correct 4 ms 4864 KB Output is correct
17 Correct 1 ms 640 KB Output is correct
18 Correct 12 ms 8960 KB Output is correct
19 Correct 7 ms 8832 KB Output is correct
20 Correct 8 ms 8832 KB Output is correct
21 Correct 9 ms 9088 KB Output is correct
22 Correct 7 ms 8832 KB Output is correct
23 Correct 7 ms 8832 KB Output is correct
24 Correct 9 ms 8960 KB Output is correct
25 Correct 7 ms 8832 KB Output is correct
26 Correct 6 ms 8832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 544 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 640 KB Output is correct
5 Correct 2 ms 1536 KB Output is correct
6 Correct 2 ms 1408 KB Output is correct
7 Correct 2 ms 1408 KB Output is correct
8 Correct 1 ms 1536 KB Output is correct
9 Correct 1 ms 1408 KB Output is correct
10 Correct 1 ms 1408 KB Output is correct
11 Correct 2 ms 1536 KB Output is correct
12 Correct 1 ms 1408 KB Output is correct
13 Correct 1 ms 1408 KB Output is correct
14 Correct 8 ms 7936 KB Output is correct
15 Correct 3 ms 3968 KB Output is correct
16 Correct 4 ms 4864 KB Output is correct
17 Correct 1 ms 640 KB Output is correct
18 Correct 12 ms 8960 KB Output is correct
19 Correct 7 ms 8832 KB Output is correct
20 Correct 8 ms 8832 KB Output is correct
21 Correct 9 ms 9088 KB Output is correct
22 Correct 7 ms 8832 KB Output is correct
23 Correct 7 ms 8832 KB Output is correct
24 Correct 9 ms 8960 KB Output is correct
25 Correct 7 ms 8832 KB Output is correct
26 Correct 6 ms 8832 KB Output is correct
27 Correct 229 ms 175100 KB Output is correct
28 Correct 12 ms 19840 KB Output is correct
29 Correct 11 ms 14080 KB Output is correct
30 Correct 1 ms 1024 KB Output is correct
31 Correct 160 ms 131232 KB Output is correct
32 Correct 149 ms 182904 KB Output is correct
33 Correct 141 ms 183416 KB Output is correct
34 Correct 184 ms 152120 KB Output is correct
35 Correct 150 ms 182904 KB Output is correct
36 Correct 151 ms 183416 KB Output is correct
37 Correct 224 ms 184056 KB Output is correct
38 Correct 107 ms 130424 KB Output is correct
39 Correct 101 ms 130808 KB Output is correct