Submission #414070

#TimeUsernameProblemLanguageResultExecution timeMemory
414070HediChehaidarCrocodile's Underground City (IOI11_crocodile)C++17
46 / 100
4 ms3276 KiB
/* ID: hedichehaidar TASK: photo LANG: C++11 */ #include<bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef double db; ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD) ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM) #define ss second #define ff first #define all(x) (x).begin() , (x).end() #define pb push_back #define vi vector<int> #define vii vector<pair<int,int>> #define vl vector<ll> #define vll vector<pair<ll,ll>> #define pii pair<int,int> #define pll pair<ll,ll> #define pdd pair<double,double> #define vdd vector<pdd> #define dte tuple<double , double , double> using namespace std; const int INF = 1000*1000*1000; // 1 e 9 const int MOD = INF + 7; const double EPS = 0.000000001; // 1 e -9 const ll inf = (ll)1e18; int n; vii adj[(int)1e5 + 10]; bool ok[(int)1e5 + 10]; bool vis[(int)1e5 + 10]; int dp[(int)1e5 + 10]; int solve(int pos){ if(ok[pos]) return 0; //if(dp[pos] != -1) return dp[pos]; if(vis[pos]) return MOD; vis[pos] = true; vi res; for(auto c : adj[pos]){ res.pb(solve(c.ff) + c.ss); } sort(all(res)); /* return dp[pos] = */return res[1]; } int travel_plan(int N , int M , int R[][2] , int L[] , int K , int P[]){ n = N; for(int i = 0 ; i < M ; i++){ int a = R[i][0] , b = R[i][1] , w = L[i]; adj[a].pb({b , w}); adj[b].pb({a , w}); } for(int i = 0 ; i < K; i++) ok[P[i]] = true; memset(dp , -1 , sizeof dp); return solve(0); } /*int main() { //ifstream fin ("race.in"); //ofstream fout ("race.out"); ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); int N , M ; cin>>N>>M; int R[M][2] , L[M] , K ; cin>>K; for(int i = 0 ; i < M ; i++){ cin>>R[i][0]>>R[i][1]>>L[i]; } int P[K]; for(int i = 0 ; i < K ; i++) cin>>P[i]; cout << travel_plan(N , M , R , L , K , P); return 0; }*/ /* 5 7 2 0 2 4 0 3 3 3 2 2 2 1 10 0 1 100 0 4 7 3 4 9 1 3 */ /* Think of : BS / DFS / BFS / SSSP / SCC / MSP / MAX FLOW / TOPSORT / LCA / MATRIX / DP(bitmask) / 2 POINTERS / SEG TREE / MATH / UN FIND / MO Read the statement CAREFULLY !! Make a GREADY APPROACH !!!! (start from highest / lowest) Make your own TESTS !! Be careful from CORNER CASES ! */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...