QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#75233#3871. Voting CitieshassybirobiroCompile Error//C++174.1kb2023-02-04 16:59:282023-02-04 16:59:32

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-04 16:59:32]
  • Judged
  • [2023-02-04 16:59:28]
  • Submitted

answer

#include <bits/stdc++.h>
#include <sys/time.h>


using namespace std;


using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<long>;
using vvl = vector<vl>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vstr = vector<string>;
constexpr ll INF_LL=1e17;
constexpr int INF_I=1LL<<30;
constexpr ll inf = 1e12 + 7;
#define rep(i,n) for(int i=0; i<((int)(n)); i++)
#define reps(i,n) for(int i=1; i<=((int)(n)); i++)
#define vector_cin(x) for(auto &n : (x)) cin >> n
#define ALL(x) (x).begin(), (x).end()
#define YesNo(x) ((x) ? "Yes": "No")
#define pb emplace_back
#define to_lower(S) transform(ALL((S)), (S).begin(), ::tolower)
#define to_upper(S) transform(ALL((S)), (S).begin(), ::toupper)
template <typename T>
bool chmax(T &a, const T& b) {if (a < b){a = b;return true;}return false;}

template <typename T>
bool chmin(T &a, const T& b) {if (a > b){a = b;return true;}return false;}
ll ceilint(ll x, ll y) {return (x + y - 1) / y;}
void Main();
int main() {std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);std::cout << std::fixed << std::setprecision(15);Main();return 0;}

//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

struct edge{
    ll to, cost;
    edge(ll t, ll c) : to(t), cost(c) {};
};

using Graph = vector<vector<edge>>;

vll dijikstra(Graph& G, ll s, ll N, vll& prev) {
    vll dist(N, INF_LL);
    dist[s] = 0;
    priority_queue<pll, vpll, greater<pll>> Q;
    Q.push({dist[s], s});
    while (!Q.empty()) {
        ll v = Q.top().second;
        ll c = Q.top().first;
        Q.pop();
        if (dist[v] < c) continue;
        for (auto& e : G[v]) {
            if (dist[e.to] > e.cost + c) {
                dist[e.to] = e.cost + c;
                prev[e.to] = v;
                Q.push({dist[e.to], e.to});
            }
        }
    }
    return dist;
}

vll getpath(vll& prev, ll g) {
    vll path;
    for (int cur = g; cur != -1; cur = prev[cur])
        path.pb(cur);
    reverse(ALL(path));
    return path;
}

void Main () {
    ll N, E, K;
    cin >> N >> E >> K;
    Graph G(N);
    vll T(K);
    vvll edge_cost(N, vll(N, -1));
    vector_cin(T);
    rep(i, E) {
        ll U, V, C;
        cin >> U >> V >> C;
        edge_cost[U][V] = C;
        G[U].pb(edge(V, C));
    }
    ll Q;
    cin >> Q;
    if (Q == 1 && K == 1) {
        ll S;
        cin >> S;
        auto d = dijikstra(G, S, N, vll(N ,-1));
        cout << d[T[0]] << endl;
    }
    while (Q--) {
        ll S;
        cin >> S;
        vll P(5);
        rep(i, 5) cin >> P[i];
        ll ans = INF_LL;
        vll d, path, prev(N, -1);
        d = dijikstra(G, S, N, prev);
        for (auto& t : T) {
            if (d[t] == INF_LL)
                continue;
            vll costs;
            path = getpath(prev, t);
            rep(i, path.size()) {
                if (i > 0) {
                    costs.pb(edge_cost[path[i - 1]][path[i]]);
                }
            }
            sort(ALL(costs), greater<ll>());
            for (int bit = 0; bit < (1LL << 5); bit++) {
                vll V;
                rep(i, 5) if (bit & (1LL << i)) V.pb(i);
                reverse(ALL(V));
                ll dist =  d[t];
                ll j = 0;
                rep(i, V.size()) {
                    if (P[V[i]] == -1) continue;
                    if (P[V[i]] > (costs[j] / 10) * (V[i] + 1)) {
                        dist = INF_LL;
                        break;
                    }
                    dist += P[V[i]];
                    dist -= (costs[j] / 10) * (V[i] + 1);
                    j++;
                    if (j >= costs.size()) break;
                }
                chmin(ans, dist);
            }
        }
        if (ans != INF_LL) 
            cout << ans << endl;
        else 
            cout << -1 << endl;
    }
}

详细

answer.code: In function ‘void Main()’:
answer.code:101:37: error: cannot bind non-const lvalue reference of type ‘vll&’ {aka ‘std::vector<long long int>&’} to an rvalue of type ‘vll’ {aka ‘std::vector<long long int>’}
  101 |         auto d = dijikstra(G, S, N, vll(N ,-1));
      |                                     ^~~~~~~~~~
answer.code:54:42: note:   initializing argument 4 of ‘vll dijikstra(Graph&, ll, ll, vll&)’
   54 | vll dijikstra(Graph& G, ll s, ll N, vll& prev) {
      |                                     ~~~~~^~~~