QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#75200#3871. Voting CitieshassybirobiroCompile Error//C++174.4kb2023-02-04 16:35:352023-02-04 16:35:38

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:35:38]
  • Judged
  • [2023-02-04 16:35:35]
  • 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=1LL<<62;
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>>;

vector<int> dijkstra(vector<vector<edge>> graph, int n, int start, int INF) {
    priority_queue<P, vector<P>, greater<P>> que;
    vector<int> dst(n, INF);
    dst[start] = 0;
    que.push(P(0, start));
    while (que.size())
    {
        int d = que.top().first;
        int u = que.top().second;
        que.pop();
        if (dst[u] < d)
            continue;
        for (int i = 0; i < graph[u].size(); ++i)
        {
            int v = graph[u][i].to;
            int cost = graph[u][i].cost;
            if (dst[v] > d + cost)
            {
                dst[v] = d + cost;
                que.push(P(dst[v], v));
            }
        }
    }
    return dst;
}

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;
        vll P(5);
        rep(i, 5) cin >> P[i];
        vll d, path, prev(N, -1);
        d = dijikstra(G, S, N, prev, INF_I);
        if (d[T[0]] == INF_LL) cout << -1 << endl;
        else cout << d[T[0]] << endl;
        return;
    }
    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 ‘std::vector<int> dijkstra(std::vector<std::vector<edge> >, int, int, int)’:
answer.code:55:20: error: ‘P’ was not declared in this scope
   55 |     priority_queue<P, vector<P>, greater<P>> que;
      |                    ^
answer.code:55:31: error: template argument 2 is invalid
   55 |     priority_queue<P, vector<P>, greater<P>> que;
      |                               ^
answer.code:55:43: error: template argument 1 is invalid
   55 |     priority_queue<P, vector<P>, greater<P>> que;
      |                                           ^~
answer.code:55:43: error: template argument 2 is invalid
answer.code:55:43: error: template argument 3 is invalid
answer.code:58:9: error: request for member ‘push’ in ‘que’, which is of non-class type ‘int’
   58 |     que.push(P(0, start));
      |         ^~~~
answer.code:59:16: error: request for member ‘size’ in ‘que’, which is of non-class type ‘int’
   59 |     while (que.size())
      |                ^~~~
answer.code:61:21: error: request for member ‘top’ in ‘que’, which is of non-class type ‘int’
   61 |         int d = que.top().first;
      |                     ^~~
answer.code:62:21: error: request for member ‘top’ in ‘que’, which is of non-class type ‘int’
   62 |         int u = que.top().second;
      |                     ^~~
answer.code:63:13: error: request for member ‘pop’ in ‘que’, which is of non-class type ‘int’
   63 |         que.pop();
      |             ^~~
answer.code:73:21: error: request for member ‘push’ in ‘que’, which is of non-class type ‘int’
   73 |                 que.push(P(dst[v], v));
      |                     ^~~~
answer.code: In function ‘void Main()’:
answer.code:109:13: error: ‘dijikstra’ was not declared in this scope; did you mean ‘dijkstra’?
  109 |         d = dijikstra(G, S, N, prev, INF_I);
      |             ^~~~~~~~~
      |             dijkstra
answer.code:121:13: error: ‘dijikstra’ was not declared in this scope; did you mean ‘dijkstra’?
  121 |         d = dijikstra(G, S, N, prev);
      |             ^~~~~~~~~
      |             dijkstra