QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#534251#1490. Road ClosuresotariusCompile Error//C++142.6kb2024-08-26 22:42:312024-08-26 22:42:31

Judging History

你现在查看的是最新测评结果

  • [2024-08-26 22:42:31]
  • 评测
  • [2024-08-26 22:42:31]
  • 提交

answer

// #include "jumps.h"
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ull unsigned long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

#define int long long
// #define int unsigned long long

// #define ordered_set(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
// #define ordered_multiset(T) tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>

void open_file(string filename) {
    freopen((filename + ".in").c_str(), "r", stdin);
    freopen((filename + ".out").c_str(), "w", stdout);
}

// const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll inf = 1e9;
const ll biginf = 1e18;
const int maxN = 2 * 1e5 + 25;

ll dp[maxN][2];
vector<pii> g[maxN];
void dfs(int v, int x, int k, int par = -1) {
    if (dp[v][x] != -1)
        return dp[v][x];
    dp[v][x] = 0;
    vector<ll> t;
    for (pii u : g[v]) {
        if (u.ff == par) {
            if (x) dp[v][x] += u.sc;
            continue;
        }
        dfs(u.ff, 0, k, v);
        dfs(u.ff, 1, k, v);
        dp[v][x] += dp[u.ff][0];
        t.pb(dp[u.ff][1] - dp[u.ff][0]);
    } sort(all(t));
    for (int i = 0; i < (int)g[v].size() - k - x || i < t.size() && t[i] < 0; i++) {
        dp[v][x] += t[i];
    }
}
vector<ll> minimum_closure_costs(int32_t n, vector<int32_t> u, vector<int32_t> v, vector<int32_t> w) {
    vector<ll> ans; ans.pb(0);
    for (int i = 0; i < n - 1; i++) {
        ans[0] += w[i];
        g[u[i]].pb({v[i], w[i]});
        g[v[i]].pb({u[i], w[i]});
    } for (int i = 1; i < n; i++) {
        for (int j = 0; j < n; j++)
            dp[j][0] = dp[j][1] = -1;
        dfs(0, 0, i); ans.pb(dp[0][0]);
    } return ans;
}
// int main() {
//   int N;
//   assert(1 == scanf("%d", &N));

//   std::vector<int> U(N - 1), V(N - 1), W(N - 1);
//   for (int i = 0; i < N - 1; ++i) {
//     assert(3 == scanf("%d %d %d", &U[i], &V[i], &W[i]));
//   }

//   std::vector<long long> closure_costs = minimum_closure_costs(N, U, V, W);
//   for (int i = 0; i < static_cast<int>(closure_costs.size()); ++i) {
//     if (i > 0) {
//       printf(" ");
//     }
//     printf("%lld",closure_costs[i]);
//   }
//   printf("\n");
//   return 0;
// }

Details

answer.code: In function ‘void dfs(long long int, long long int, long long int, long long int)’:
answer.code:43:23: error: return-statement with a value, in function returning ‘void’ [-fpermissive]
   43 |         return dp[v][x];
      |                ~~~~~~~^
answer.code: In function ‘void open_file(std::string)’:
answer.code:28:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |     freopen((filename + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:29:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |     freopen((filename + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~