Submission #74232042


Source Code Expand

#include <bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<long long> vll;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
//#define endl '\n'
ll mod = 1e9+7 ;
int p1 = 31 , p2 = 91 ;
ll mod1= 1e9+7 , mod2 = 1e9+9 ;


void solve() {
    ll h , w , x ; cin >> h >> w >> x ;
    ll p , q ; cin >> p >> q ;
    ll adj[h][w] ;
    for(int i = 0 ; i < h ; ++i) {
        for(int j = 0 ; j < w  ;++j) {
            cin >>adj[i][j];
        }
    }
    set<pair<ll,pair<ll,ll>>> e ;
    ll ans = adj[p-1][q-1] ;
    int visited[h][w] ;
    memset(visited,0,sizeof(visited)) ;
    visited[p-1][q-1] = 1 ;
    vector<int> v= {-1,0,+1,0} , vv ={0,1,0,-1};
    for(int i = 0 ; i < 4 ; ++i) {
        int x = p-1 + v[i] ;
        int y = q-1 + vv[i] ;
        if(x<h && x>=0 && y<w && y>=0) {
            e.insert({adj[x][y],{x,y}}) ;
        }
    }


    while(! e.empty()) {

        auto it  = e.begin();
        auto i = *it ;
        e.erase(it) ;
        visited[i.second.first][i.second.second] = 1 ;

        if((1.0 *i.first)  >= ((1.0*ans)/x ) ) break ;
        ans+=i.first ;
        for(int ii = 0 ; ii < 4 ; ++ii) {
            int x = i.second.first + v[ii] ;
            int y = i.second.second + vv[ii] ;
            if(x<h && x>=0 && y<w && y>=0 && (!visited[x][y])) {
                e.insert({adj[x][y],{x,y}}) ;
            }
        }

    }
    cout << ans << endl ;
    
}




int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Submission Info

Submission Time
Task H - Takahashi is Slime 2
User Code_Pro
Language C++23 (GCC 15.2.0)
Score 450
Code Size 1724 Byte
Status WA
Exec Time 135 ms
Memory 16944 KiB

Judge Result

Set Name Sample All after_contest
Score / Max Score 0 / 0 450 / 450 0 / 0
Status
AC × 3
AC × 65
WA × 1
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 01_random_45.txt, 01_random_46.txt, 01_random_47.txt, 01_random_48.txt, 01_random_49.txt, 01_random_50.txt, 01_random_51.txt, 01_random_52.txt, 01_random_53.txt, 01_random_54.txt, 01_random_55.txt, 01_random_56.txt, 01_random_57.txt, 01_random_58.txt, 01_random_59.txt, 01_random_60.txt, 01_random_61.txt, 01_random_62.txt, 01_random_63.txt, 01_random_64.txt
after_contest 02_after_contest_65.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 2 ms 3576 KiB
00_sample_01.txt AC 1 ms 3604 KiB
00_sample_02.txt AC 2 ms 3572 KiB
01_random_03.txt AC 112 ms 10232 KiB
01_random_04.txt AC 5 ms 3840 KiB
01_random_05.txt AC 134 ms 11520 KiB
01_random_06.txt AC 21 ms 5552 KiB
01_random_07.txt AC 132 ms 11792 KiB
01_random_08.txt AC 5 ms 3872 KiB
01_random_09.txt AC 135 ms 11704 KiB
01_random_10.txt AC 16 ms 4984 KiB
01_random_11.txt AC 15 ms 6456 KiB
01_random_12.txt AC 2 ms 3632 KiB
01_random_13.txt AC 15 ms 6456 KiB
01_random_14.txt AC 9 ms 4404 KiB
01_random_15.txt AC 107 ms 10904 KiB
01_random_16.txt AC 2 ms 3640 KiB
01_random_17.txt AC 132 ms 11640 KiB
01_random_18.txt AC 5 ms 4064 KiB
01_random_19.txt AC 92 ms 9976 KiB
01_random_20.txt AC 5 ms 4528 KiB
01_random_21.txt AC 106 ms 11320 KiB
01_random_22.txt AC 3 ms 3880 KiB
01_random_23.txt AC 14 ms 6460 KiB
01_random_24.txt AC 4 ms 4272 KiB
01_random_25.txt AC 15 ms 6400 KiB
01_random_26.txt AC 2 ms 3704 KiB
01_random_27.txt AC 14 ms 6392 KiB
01_random_28.txt AC 5 ms 4400 KiB
01_random_29.txt AC 16 ms 6520 KiB
01_random_30.txt AC 7 ms 4632 KiB
01_random_31.txt AC 15 ms 6548 KiB
01_random_32.txt AC 5 ms 4280 KiB
01_random_33.txt AC 15 ms 6512 KiB
01_random_34.txt AC 9 ms 5124 KiB
01_random_35.txt AC 14 ms 6456 KiB
01_random_36.txt AC 2 ms 3960 KiB
01_random_37.txt AC 14 ms 6440 KiB
01_random_38.txt AC 5 ms 4256 KiB
01_random_39.txt AC 16 ms 6544 KiB
01_random_40.txt AC 3 ms 3796 KiB
01_random_41.txt AC 15 ms 6392 KiB
01_random_42.txt AC 6 ms 4352 KiB
01_random_43.txt AC 2 ms 3484 KiB
01_random_44.txt AC 2 ms 3448 KiB
01_random_45.txt AC 1 ms 3496 KiB
01_random_46.txt AC 1 ms 3552 KiB
01_random_47.txt AC 1 ms 3456 KiB
01_random_48.txt AC 2 ms 3632 KiB
01_random_49.txt AC 2 ms 3600 KiB
01_random_50.txt AC 1 ms 3412 KiB
01_random_51.txt AC 3 ms 3600 KiB
01_random_52.txt AC 1 ms 3512 KiB
01_random_53.txt AC 1 ms 3512 KiB
01_random_54.txt AC 1 ms 3604 KiB
01_random_55.txt AC 2 ms 3508 KiB
01_random_56.txt AC 2 ms 3568 KiB
01_random_57.txt AC 1 ms 3632 KiB
01_random_58.txt AC 88 ms 16944 KiB
01_random_59.txt AC 98 ms 16808 KiB
01_random_60.txt AC 105 ms 16768 KiB
01_random_61.txt AC 2 ms 3496 KiB
01_random_62.txt AC 2 ms 3496 KiB
01_random_63.txt AC 1 ms 3448 KiB
01_random_64.txt AC 2 ms 3608 KiB
02_after_contest_65.txt WA 27 ms 6676 KiB