Submission #63286052


Source Code Expand

Copy
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rrep(i,n) for(ll i=n-1; i>=0; i--)
#define fi first
#define se second
#define pcnt __builtin_popcountll
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
string zero_padding(int val, int nf){ ostringstream sout;sout << setfill('0') << setw(nf) << val; return sout.str();};
const ld eps = 1e-10;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rrep(i,n) for(ll i=n-1; i>=0; i--)
#define fi first
#define se second
#define pcnt __builtin_popcountll
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
string zero_padding(int val, int nf){ ostringstream sout;sout << setfill('0') << setw(nf) << val; return sout.str();};
const ld eps = 1e-10;
const ll INF = 1e18; 
ull mo = 1000000007;
ld PI=asin(1)*2;
//using namespace atcoder;

using TU = tuple<ll,ll,ll>;
int main(){
    ll N,M,X;
    cin >> N >> M >> X;
    vector<vector<ll>> G(N), H(N);
    rep(i,M){
        ll u,v;
        cin >> u >> v;
        u--;v--;
        G[u].push_back(v);
        H[v].push_back(u);
    }
    vector<vector<ll>> d1(N,vector<ll>(2,1e18));
    priority_queue<TU, vector<TU>, greater<TU>> que;
    que.push({0,0,0});
    while(!que.empty()){
        auto [c,v,t] = que.top();
        que.pop();
        //if(d1[v] <= cost) continue;
        if(d1[v][t] != 1e18) continue;
        d1[v][t] = c;
        if(t == 0){
            for(auto& u:G[v]){
                que.push({c+1,u,0});
            }
            for(auto& u:H[v]){
                que.push({c+X+1,u,1});
            }
        }else{
            for(auto& u:G[v]){
                que.push({c+X+1,u,0});
            }
            for(auto& u:H[v]){
                que.push({c+1,u,1});
            }                
        }
    }
    cout << min(d1[N-1][0], d1[N-1][1]) << endl;
}

Submission Info

Submission Time
Task E - Flip Edge
User zssa
Language C++ 20 (gcc 12.2)
Score 425
Code Size 2021 Byte
Status AC
Exec Time 355 ms
Memory 44292 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 4
AC × 70
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_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, 01_random_65.txt, 01_random_66.txt, 01_random_67.txt, 01_random_68.txt, 01_random_69.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3684 KB
00_sample_01.txt AC 1 ms 3504 KB
00_sample_02.txt AC 1 ms 3500 KB
00_sample_03.txt AC 1 ms 3496 KB
01_random_04.txt AC 348 ms 38216 KB
01_random_05.txt AC 204 ms 33316 KB
01_random_06.txt AC 256 ms 32788 KB
01_random_07.txt AC 349 ms 38232 KB
01_random_08.txt AC 231 ms 33296 KB
01_random_09.txt AC 283 ms 32920 KB
01_random_10.txt AC 342 ms 38236 KB
01_random_11.txt AC 221 ms 33300 KB
01_random_12.txt AC 257 ms 32852 KB
01_random_13.txt AC 348 ms 38208 KB
01_random_14.txt AC 222 ms 33328 KB
01_random_15.txt AC 274 ms 32748 KB
01_random_16.txt AC 334 ms 38260 KB
01_random_17.txt AC 211 ms 33376 KB
01_random_18.txt AC 288 ms 32892 KB
01_random_19.txt AC 347 ms 38236 KB
01_random_20.txt AC 230 ms 33308 KB
01_random_21.txt AC 262 ms 33016 KB
01_random_22.txt AC 328 ms 38144 KB
01_random_23.txt AC 213 ms 33412 KB
01_random_24.txt AC 281 ms 32932 KB
01_random_25.txt AC 317 ms 38124 KB
01_random_26.txt AC 219 ms 33324 KB
01_random_27.txt AC 273 ms 32936 KB
01_random_28.txt AC 355 ms 38236 KB
01_random_29.txt AC 221 ms 33564 KB
01_random_30.txt AC 263 ms 32936 KB
01_random_31.txt AC 318 ms 33684 KB
01_random_32.txt AC 57 ms 10804 KB
01_random_33.txt AC 110 ms 17980 KB
01_random_34.txt AC 198 ms 31344 KB
01_random_35.txt AC 112 ms 16656 KB
01_random_36.txt AC 135 ms 19908 KB
01_random_37.txt AC 241 ms 24640 KB
01_random_38.txt AC 59 ms 22440 KB
01_random_39.txt AC 124 ms 17896 KB
01_random_40.txt AC 183 ms 29272 KB
01_random_41.txt AC 101 ms 25788 KB
01_random_42.txt AC 25 ms 7384 KB
01_random_43.txt AC 233 ms 29280 KB
01_random_44.txt AC 65 ms 16208 KB
01_random_45.txt AC 259 ms 31824 KB
01_random_46.txt AC 210 ms 32956 KB
01_random_47.txt AC 224 ms 44292 KB
01_random_48.txt AC 207 ms 33036 KB
01_random_49.txt AC 219 ms 44260 KB
01_random_50.txt AC 212 ms 32976 KB
01_random_51.txt AC 216 ms 44256 KB
01_random_52.txt AC 195 ms 32652 KB
01_random_53.txt AC 225 ms 44128 KB
01_random_54.txt AC 195 ms 33068 KB
01_random_55.txt AC 223 ms 44176 KB
01_random_56.txt AC 190 ms 29860 KB
01_random_57.txt AC 198 ms 29820 KB
01_random_58.txt AC 195 ms 29760 KB
01_random_59.txt AC 268 ms 35904 KB
01_random_60.txt AC 267 ms 35880 KB
01_random_61.txt AC 263 ms 36064 KB
01_random_62.txt AC 251 ms 25812 KB
01_random_63.txt AC 269 ms 25772 KB
01_random_64.txt AC 251 ms 25876 KB
01_random_65.txt AC 1 ms 3552 KB
01_random_66.txt AC 1 ms 3552 KB
01_random_67.txt AC 1 ms 3644 KB
01_random_68.txt AC 13 ms 21892 KB
01_random_69.txt AC 6 ms 11536 KB


2025-04-15 (Tue)
11:54:58 +00:00