Submission #913658

# Submission time Handle Problem Language Result Execution time Memory
913658 2024-01-20T08:39:22 Z Mahdiyar1 Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
413 ms 221528 KB
// #pragma GCC optimize("Ofast", "unroll-loops")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <stack>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <bitset>
#include <cstring>
using namespace std;
typedef long long ll;

#define debug(i) cout << "#pass " << i<<endl
#define Kawasaki ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
// #define int ll
#define vi vector<int>
#define vii vector<vector<int> >
#define qi queue<int>
#define sort(v) sort(v.begin() , v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define all(v) v.begin() , v.end()
#define pii pair<int,int>
#define bs bitset
#define mkp(x,y) make_pair(x , y)
#define fi first
#define se second

const int maxn = 3e3 + 10;
const int maxa = 2e3 + 10;
const int lg = 21;
const int mod = 1e9 + 7;
// const int INF = 1e18 + 10;
const int len = 320;
//int p = 31 , q = 53 , pp = 1 , qq = 1;
// int pow(int a , int b , int _mod = mod){
//     return b ? pow(a*a%_mod , b>>1ll,_mod) * (b&1 ? a : 1) %_mod: 1;
// }
//pii mv[8] = {mkp(1,2) , mkp(-1,2) , mkp(1,-2) , mkp(-1,-2) , mkp(2,1) , mkp(2,-1) , mkp(-2,1) , mkp(-2,-1)};
pii mv[4] = {mkp(1,0) , mkp(-1,0) , mkp(0,1) , mkp(0,-1)};

int n , m , cnt[3][maxn][maxn] , ant[3][maxn][maxn];
string mp[maxn];

void solve(){
    cin >> n >> m;
    for(int i=1;i<=n;i++){
        cin >> mp[i];
        mp[i] = "." + mp[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int x = 0;
            if(mp[i][j] == 'O')x=1;
            else if(mp[i][j] == 'I')x=2;
            cnt[0][i][j] = cnt[0][i][j-1];ant[0][j][i] = ant[0][j][i-1];
            cnt[1][i][j] = cnt[1][i][j-1];ant[1][j][i] = ant[1][j][i-1];
            cnt[2][i][j] = cnt[2][i][j-1];ant[2][j][i] = ant[2][j][i-1];
            cnt[x][i][j] += 1;
            ant[x][j][i] += 1;
        }
    }
    ll ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(mp[i][j] != 'J')continue;
            ans += (cnt[1][i][m] - cnt[1][i][j]) * (ant[2][j][n] - ant[2][j][i]);
        }
        // cout << i << ' ' << ans << endl;
    } 
    cout << ans;
}

signed main(){
    Kawasaki;
    int T = 1 , TT = 1;
//    cin >> T;
    while(T--){
        solve();
    }
}


Compilation message

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:87:17: warning: unused variable 'TT' [-Wunused-variable]
   87 |     int T = 1 , TT = 1;
      |                 ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 3160 KB Output is correct
6 Correct 3 ms 2904 KB Output is correct
7 Correct 3 ms 2904 KB Output is correct
8 Correct 2 ms 3164 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 2 ms 2908 KB Output is correct
11 Correct 3 ms 3164 KB Output is correct
12 Correct 2 ms 3084 KB Output is correct
13 Correct 2 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 3160 KB Output is correct
6 Correct 3 ms 2904 KB Output is correct
7 Correct 3 ms 2904 KB Output is correct
8 Correct 2 ms 3164 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 2 ms 2908 KB Output is correct
11 Correct 3 ms 3164 KB Output is correct
12 Correct 2 ms 3084 KB Output is correct
13 Correct 2 ms 2908 KB Output is correct
14 Correct 11 ms 17500 KB Output is correct
15 Correct 4 ms 5744 KB Output is correct
16 Correct 11 ms 12892 KB Output is correct
17 Correct 3 ms 4184 KB Output is correct
18 Correct 20 ms 20520 KB Output is correct
19 Correct 17 ms 19980 KB Output is correct
20 Correct 21 ms 20316 KB Output is correct
21 Correct 18 ms 20312 KB Output is correct
22 Correct 17 ms 20056 KB Output is correct
23 Correct 18 ms 20356 KB Output is correct
24 Correct 18 ms 20504 KB Output is correct
25 Correct 16 ms 19956 KB Output is correct
26 Correct 15 ms 20312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 3160 KB Output is correct
6 Correct 3 ms 2904 KB Output is correct
7 Correct 3 ms 2904 KB Output is correct
8 Correct 2 ms 3164 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 2 ms 2908 KB Output is correct
11 Correct 3 ms 3164 KB Output is correct
12 Correct 2 ms 3084 KB Output is correct
13 Correct 2 ms 2908 KB Output is correct
14 Correct 11 ms 17500 KB Output is correct
15 Correct 4 ms 5744 KB Output is correct
16 Correct 11 ms 12892 KB Output is correct
17 Correct 3 ms 4184 KB Output is correct
18 Correct 20 ms 20520 KB Output is correct
19 Correct 17 ms 19980 KB Output is correct
20 Correct 21 ms 20316 KB Output is correct
21 Correct 18 ms 20312 KB Output is correct
22 Correct 17 ms 20056 KB Output is correct
23 Correct 18 ms 20356 KB Output is correct
24 Correct 18 ms 20504 KB Output is correct
25 Correct 16 ms 19956 KB Output is correct
26 Correct 15 ms 20312 KB Output is correct
27 Correct 375 ms 215216 KB Output is correct
28 Correct 19 ms 29044 KB Output is correct
29 Correct 48 ms 50512 KB Output is correct
30 Correct 19 ms 28648 KB Output is correct
31 Correct 272 ms 183924 KB Output is correct
32 Correct 318 ms 220620 KB Output is correct
33 Correct 349 ms 221092 KB Output is correct
34 Correct 344 ms 200032 KB Output is correct
35 Correct 379 ms 220724 KB Output is correct
36 Correct 367 ms 221192 KB Output is correct
37 Correct 413 ms 221528 KB Output is correct
38 Correct 261 ms 183028 KB Output is correct
39 Correct 265 ms 183764 KB Output is correct