Submission #554155

#TimeUsernameProblemLanguageResultExecution timeMemory
554155Zhora_004Road Closures (APIO21_roads)C++17
12 / 100
52 ms12620 KiB
#include "roads.h" #include <iostream> #include <cmath> #include <algorithm> #include <vector> #include <set> #include <unordered_set> #include <queue> #include <deque> #include <string> #include <sstream> #include <iomanip> #include <map> #include <unordered_map> #include <stack> #include <cstdio> #include <climits> #include <tuple> #include <ctime> #include <cstring> #include <numeric> #include <functional> #include <chrono> #include <cassert> #include <bitset> #include <fstream> //#include <bit> //#include <ranges> //#include <numbers> #define sz(a) ((int)((a).size())) // printf("%.10f\n", ans); /*ofstream fout("timeline.out"); ifstream fin("timeline.in");*/ using ll = long long; using namespace std; int n; vector<int> a, b, c; bool task(int id) { if (id == 1) { for (int& i : a) if (i) return 0; return 1; } if (id == 2) { for (int i = 0; i < n - 1; i++) if (a[i] != i || b[i] != i + 1) return 0; return 1; } return 0; } std::vector<long long> minimum_closure_costs(int N, std::vector<int> U, std::vector<int> V, std::vector<int> W) { n = N; a = U; b = V; c = W; if (task(1)) { vector<ll> res; ll sum = 0; for (int& i : c) sum += i; res.push_back(sum); sort(c.begin(), c.end()); reverse(c.begin(), c.end()); for (int k = 0; k < n - 1; k++) { sum -= c[k]; res.push_back(sum); } return res; } if (task(2)) { ll sum = 0; vector<vector<ll>> dp(n, vector<ll>(2)); for (int i = 1; i < n; i++) { dp[i][0] = dp[i - 1][1]; dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + c[i - 1]; sum += c[i - 1]; } vector<ll> res; res.push_back(sum); res.push_back(min(dp[n - 1][0], dp[n - 1][1])); for (int k = 2; k < n; k++) res.push_back(0); return res; } }

Compilation message (stderr)

roads.cpp: In function 'std::vector<long long int> minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)':
roads.cpp:90:1: warning: control reaches end of non-void function [-Wreturn-type]
   90 | }
      | ^
#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...