Submission #1072066

#TimeUsernameProblemLanguageResultExecution timeMemory
1072066mindiyakClosing Time (IOI23_closing)C++17
8 / 100
156 ms22100 KiB
#include "closing.h" #pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops") #include <bits/stdc++.h> #include <string> #include <iostream> #include <cmath> #include <numeric> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pi; typedef pair<int, int> pl; typedef pair<ld, ld> pd; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<vector<int>> vvi; typedef vector<vector<ll>> vvl; typedef vector<ld> vd; typedef vector<ll> vl; typedef vector<pi> vpi; typedef vector<pl> vpl; #define FOR(i, a, b) for (int i = a; i < (b); i++) #define F0R(i, a) for (int i = 0; i < (a); i++) #define FORd(i, a, b) for (int i = (b)-1; i >= a; i--) #define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--) #define trav(a, x) for (auto &a : x) #define uid(a, b) uniform_int_distribution<int>(a, b)(rng) #define len(x) (int)(x).size() #define mp make_pair #define pb push_back #define F first #define nl endl #define S second #define lb lower_bound #define ub upper_bound #define aint(x) x.begin(), x.end() #define raint(x) x.rbegin(), x.rend() #define ins insert const int MOD = 1000000007; int max_score(int N, int X, int Y, ll K,vi U, vi V, vi W) { vector<vpi> paths(2e5+5); FOR(i,0,N-1){ paths[U[i]].pb({V[i],W[i]}); paths[V[i]].pb({U[i],W[i]}); } priority_queue<pair<ll,pi>> arr; vl closing_times(N,0); int ans = 0; arr.push({-0,{X,-1}}); arr.push({-0,{Y,-1}}); while(!arr.empty()){ int node = arr.top().S.F; int prev = arr.top().S.S; ll diff = -arr.top().F; arr.pop(); cerr << K << " " << diff << " " << node << endl; if(diff > K)continue; K-=diff; ans += 1; closing_times[node] += diff; for(pi edges:paths[node]){ if(edges.F == prev)continue; arr.push({-(max(closing_times[node]+edges.S-closing_times[edges.F],0LL)),{edges.F,node}}); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...