Submission #492844

# Submission time Handle Problem Language Result Execution time Memory
492844 2021-12-09T10:02:18 Z Karabasan Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
385 ms 81536 KB
#include <bits/stdc++.h>
#define ll long long
#define fast1 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,avx")
#pragma GCC optimize("unroll-loops")

int n,m;
char dizi[3005][3005];
vector<pair<int,int> > v;
int dp[3005][3005];
void solve()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            cin>>dizi[i][j];
            if(dizi[i][j]=='J')
                v.push_back({i,j});
        }
    for(int i=1;i<=n;i++)
    {
        int o=0;
        for(int j=m;j>=1;j--)
        {
            if(dizi[i][j]=='O')
                o++;
            else if(dizi[i][j]=='J')
                dp[i][j]=o;
        }
    }
    for(int i=1;i<=m;i++)
    {
        int o=0;
        for(int j=n;j>=1;j--)
        {
            if(dizi[j][i]=='I')
                o++;
            else if(dizi[j][i]=='J')
                dp[j][i]*=o;
        }
    }
    ll cvp=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        cvp+=dp[i][j];
    cout<<cvp;
}
signed main()
{
    fast1
    //freopen ("lca.gir","r",stdin);
    //freopen ("lca.cik","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 1 ms 1100 KB Output is correct
9 Correct 1 ms 1100 KB Output is correct
10 Correct 1 ms 972 KB Output is correct
11 Correct 1 ms 1100 KB Output is correct
12 Correct 1 ms 972 KB Output is correct
13 Correct 1 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 1 ms 1100 KB Output is correct
9 Correct 1 ms 1100 KB Output is correct
10 Correct 1 ms 972 KB Output is correct
11 Correct 1 ms 1100 KB Output is correct
12 Correct 1 ms 972 KB Output is correct
13 Correct 1 ms 972 KB Output is correct
14 Correct 8 ms 5068 KB Output is correct
15 Correct 1 ms 3148 KB Output is correct
16 Correct 4 ms 2892 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 10 ms 5448 KB Output is correct
19 Correct 8 ms 4560 KB Output is correct
20 Correct 6 ms 4788 KB Output is correct
21 Correct 10 ms 5768 KB Output is correct
22 Correct 9 ms 5432 KB Output is correct
23 Correct 7 ms 5064 KB Output is correct
24 Correct 12 ms 5912 KB Output is correct
25 Correct 6 ms 4816 KB Output is correct
26 Correct 7 ms 5072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 1 ms 1100 KB Output is correct
9 Correct 1 ms 1100 KB Output is correct
10 Correct 1 ms 972 KB Output is correct
11 Correct 1 ms 1100 KB Output is correct
12 Correct 1 ms 972 KB Output is correct
13 Correct 1 ms 972 KB Output is correct
14 Correct 8 ms 5068 KB Output is correct
15 Correct 1 ms 3148 KB Output is correct
16 Correct 4 ms 2892 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 10 ms 5448 KB Output is correct
19 Correct 8 ms 4560 KB Output is correct
20 Correct 6 ms 4788 KB Output is correct
21 Correct 10 ms 5768 KB Output is correct
22 Correct 9 ms 5432 KB Output is correct
23 Correct 7 ms 5064 KB Output is correct
24 Correct 12 ms 5912 KB Output is correct
25 Correct 6 ms 4816 KB Output is correct
26 Correct 7 ms 5072 KB Output is correct
27 Correct 348 ms 74744 KB Output is correct
28 Correct 8 ms 16084 KB Output is correct
29 Correct 12 ms 5364 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 259 ms 59416 KB Output is correct
32 Correct 215 ms 52900 KB Output is correct
33 Correct 229 ms 65120 KB Output is correct
34 Correct 308 ms 68956 KB Output is correct
35 Correct 246 ms 70780 KB Output is correct
36 Correct 222 ms 65084 KB Output is correct
37 Correct 385 ms 81536 KB Output is correct
38 Correct 146 ms 41160 KB Output is correct
39 Correct 155 ms 48220 KB Output is correct