Submission #1241100

#TimeUsernameProblemLanguageResultExecution timeMemory
1241100pcpCrocodile's Underground City (IOI11_crocodile)C++20
46 / 100
3 ms3908 KiB
#include "crocodile.h" #include <iostream> #include <cstring> #include <vector> #include <queue> #include <algorithm> // /usr/bin/g++ -DEVAL -std=gnu++20 -O2 -pipe -static -s -o crocodile grader.cpp crocodile.cpp using namespace std; const int NN=100010; vector<pair<int,int>> connections[NN]; bool gud[NN]; bool visited[NN]; int tumama[NN]; int depth[NN]; int dfs(int node){ if (!visited[node]){ visited[node]=true; priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> kiwi; //sort(connections[node].begin(),connections[node].end()); for (auto it : connections[node]){ if (tumama[it.second]!=-1 && depth[it.second] >= depth[node]){ pair<int,int> eso={-1,-1};eso.first=tumama[it.second]+it.first;eso.second=it.second; kiwi.push(eso); }else if (depth[it.second] >=depth[node]){ int rslt = dfs(it.second); if (gud[it.second]){ kiwi.push({it.first+rslt,it.second}); } } } if (kiwi.size()>=2)gud[node]=true; else return 0; kiwi.pop(); tumama[node]=kiwi.top().first; return kiwi.top().first; }return 0; } int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { memset(visited, 0, sizeof visited); memset(gud, 0, sizeof gud); memset(tumama, -1, sizeof tumama); memset(depth, -1, sizeof depth); for (int i = 0; i < M;++i){ connections[R[i][0]].push_back({L[i],R[i][1]}); connections[R[i][1]].push_back({L[i],R[i][0]}); } for (int i = 0;i<K;++i)gud[P[i]]=true; queue<pair<int,int>> kiwi; kiwi.push({0,0}); while (kiwi.size()>0){ pair<int,int> it = kiwi.front();kiwi.pop(); if (depth[it.first]==-1){ depth[it.first]=it.second; for (pair<int,int> i : connections[it.first]){ //cout<<"a"; pair<int,int> eso ={i.second,-1};eso.second=it.second+1; //cout<<eso.first<<" "<<eso.second<<endl;; if (depth[i.second]==-1)kiwi.push(eso); } } } memset(visited, 0, sizeof visited); return dfs(0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...