Submission #441699

# Submission time Handle Problem Language Result Execution time Memory
441699 2021-07-05T20:48:38 Z julian33 Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
572 ms 118280 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
    cerr<<vars<<" = ";
    string delim="";
    (...,(cerr<<delim<<values,delim=", "));
    cerr<<"\n";
}
#else
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {}
#endif

#define FOR(i,j,n) for(int i=j;i<n;i++)

#define pb push_back
#define sz(x) (int)(x.size())
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> inline void maxa(T& a,T b){a=max(a,b);}
template<typename T> inline void mina(T& a,T b){a=min(a,b);}

const int mxN=5e3+5;

int psaO[mxN][mxN],psaI[mxN][mxN];
char grid[mxN][mxN];

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int n,m; cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>grid[i][j];
            if(grid[i][j]=='O')
                psaO[i][j]=1;
            else if(grid[i][j]=='I')
                psaI[j][i]=1;
            psaO[i][j]+=psaO[i][j-1];
            psaI[j][i]+=psaI[j][i-1];
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(grid[i][j]!='J')
                continue;
            ll Ocnt=psaO[i][m]-psaO[i][j];
            ll Icnt=psaI[j][n]-psaI[j][i];
            ans+=Ocnt*Icnt;
        }
    }
    cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 1612 KB Output is correct
6 Correct 1 ms 1476 KB Output is correct
7 Correct 1 ms 1484 KB Output is correct
8 Correct 2 ms 1612 KB Output is correct
9 Correct 1 ms 1484 KB Output is correct
10 Correct 1 ms 1484 KB Output is correct
11 Correct 2 ms 1612 KB Output is correct
12 Correct 2 ms 1484 KB Output is correct
13 Correct 1 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 1612 KB Output is correct
6 Correct 1 ms 1476 KB Output is correct
7 Correct 1 ms 1484 KB Output is correct
8 Correct 2 ms 1612 KB Output is correct
9 Correct 1 ms 1484 KB Output is correct
10 Correct 1 ms 1484 KB Output is correct
11 Correct 2 ms 1612 KB Output is correct
12 Correct 2 ms 1484 KB Output is correct
13 Correct 1 ms 1484 KB Output is correct
14 Correct 11 ms 7756 KB Output is correct
15 Correct 2 ms 3788 KB Output is correct
16 Correct 7 ms 5720 KB Output is correct
17 Correct 1 ms 1612 KB Output is correct
18 Correct 15 ms 8784 KB Output is correct
19 Correct 11 ms 8652 KB Output is correct
20 Correct 13 ms 8636 KB Output is correct
21 Correct 14 ms 8760 KB Output is correct
22 Correct 11 ms 8652 KB Output is correct
23 Correct 11 ms 8652 KB Output is correct
24 Correct 14 ms 8780 KB Output is correct
25 Correct 10 ms 8652 KB Output is correct
26 Correct 10 ms 8652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 1612 KB Output is correct
6 Correct 1 ms 1476 KB Output is correct
7 Correct 1 ms 1484 KB Output is correct
8 Correct 2 ms 1612 KB Output is correct
9 Correct 1 ms 1484 KB Output is correct
10 Correct 1 ms 1484 KB Output is correct
11 Correct 2 ms 1612 KB Output is correct
12 Correct 2 ms 1484 KB Output is correct
13 Correct 1 ms 1484 KB Output is correct
14 Correct 11 ms 7756 KB Output is correct
15 Correct 2 ms 3788 KB Output is correct
16 Correct 7 ms 5720 KB Output is correct
17 Correct 1 ms 1612 KB Output is correct
18 Correct 15 ms 8784 KB Output is correct
19 Correct 11 ms 8652 KB Output is correct
20 Correct 13 ms 8636 KB Output is correct
21 Correct 14 ms 8760 KB Output is correct
22 Correct 11 ms 8652 KB Output is correct
23 Correct 11 ms 8652 KB Output is correct
24 Correct 14 ms 8780 KB Output is correct
25 Correct 10 ms 8652 KB Output is correct
26 Correct 10 ms 8652 KB Output is correct
27 Correct 550 ms 113316 KB Output is correct
28 Correct 11 ms 19296 KB Output is correct
29 Correct 42 ms 18340 KB Output is correct
30 Correct 7 ms 9808 KB Output is correct
31 Correct 371 ms 87648 KB Output is correct
32 Correct 474 ms 117720 KB Output is correct
33 Correct 524 ms 117956 KB Output is correct
34 Correct 484 ms 100048 KB Output is correct
35 Correct 527 ms 117696 KB Output is correct
36 Correct 524 ms 118028 KB Output is correct
37 Correct 572 ms 118280 KB Output is correct
38 Correct 329 ms 87176 KB Output is correct
39 Correct 376 ms 87384 KB Output is correct