QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#75216#3871. Voting Citieshassybirobiro0 41ms199884kbC++174.4kb2023-02-04 16:47:042023-02-04 16:47:06

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:47:06]
  • Judged
  • Verdict: 0
  • Time: 41ms
  • Memory: 199884kb
  • [2023-02-04 16:47:04]
  • 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<ll> dijkstra(vector<vector<edge>> graph, int n, int start, ll INF) {
    priority_queue<pll, vector<pll>, greater<pll>> que;
    vector<ll> dst(n, INF);
    dst[start] = 0;
    que.push(pll(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;
            ll cost = graph[u][i].cost;
            if (dst[v] > d + cost)
            {
                dst[v] = d + cost;
                que.push(pll(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 = dijkstra(G, N, S, inf);
        if (d[T[0]] == INF_LL) cout << -1 << endl;
        else cout << d[T[0]] << endl;
        return;
    } else 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;
    }*/
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 26ms
memory: 199784kb

input:

5000 10000 1
4683
0 715 579327370
0 954 664830350
0 2453 244225980
0 2918 399241150
0 3929 982683290
1 4944 723915200
2 3725 390369490
3 1370 230814450
3 3348 750421430
3 3408 503334040
4 252 852709300
4 989 474431070
4 1013 466847840
4 4956 152207550
5 4162 271201150
6 3335 991911830
6 3596 4382854...

output:

-1292841286

result:

wrong answer 1st lines differ - expected: '7570531610', found: '-1292841286'

Subtask #2:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 17ms
memory: 199284kb

input:

5000 10000 1
939
0 1074 697931020
0 4334 347738890
1 2400 681303040
2 1685 896587820
2 2368 928896100
2 3133 12276450
2 3258 765661210
4 3606 993201320
5 1081 613705100
5 2339 700470170
5 2625 209307440
5 2832 129029550
7 1517 251821020
7 1751 713428320
7 2308 951691550
7 3980 498317440
7 4014 78197...

output:


result:

wrong answer 1st lines differ - expected: '5627552460', found: ''

Subtask #3:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 37ms
memory: 199312kb

input:

5000 10000 2000
366 1016 3277 5 3742 3640 2511 1725 2168 2349 1037 4972 2930 4374 3504 1098 3439 3970 1952 3474 2664 2097 1751 3679 3155 3266 2070 2016 338 1273 2648 4398 3694 2045 3524 1027 839 1898 1795 1192 2975 1756 4707 1548 4984 1891 2364 123 3181 1096 2970 3264 1628 1295 4852 829 4940 2251 37...

output:


result:

wrong answer 1st lines differ - expected: '0', found: ''

Subtask #4:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 41ms
memory: 199884kb

input:

5000 10000 1
4577
0 248 57534230
0 3020 827662530
0 3190 138424730
1 3154 752916230
4 1256 398736840
5 4116 833556610
5 4127 547494700
6 396 793865570
6 1661 388141660
7 4581 595148940
8 3768 724151300
9 1367 840320860
9 1656 391917460
10 3210 806346090
10 3356 767016610
10 3367 272248610
12 1145 72...

output:

1000000000007

result:

wrong answer 1st lines differ - expected: '-1', found: '1000000000007'

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Wrong Answer

Test #22:

score: 0
Wrong Answer
time: 36ms
memory: 199280kb

input:

5000 10000 200
1044 1225 1941 2497 4667 2566 3603 92 2261 1826 770 4780 127 4386 1948 2156 1504 4511 3119 4006 4473 389 3469 2670 3989 3092 55 670 4525 4965 1038 375 419 2599 4912 3665 4799 2997 4759 1660 1136 2308 1707 4249 3246 625 3378 52 734 4317 4958 3355 869 3361 2010 2300 2809 2635 2241 3441 ...

output:


result:

wrong answer 1st lines differ - expected: '-1', found: ''

Subtask #7:

score: 0
Wrong Answer

Test #26:

score: 0
Wrong Answer
time: 2ms
memory: 3588kb

input:

100 1000 10
98 30 76 47 68 72 37 62 38 78
0 40 955510110
0 58 380472040
0 67 471726660
0 75 21910230
0 76 203779460
0 79 619337400
0 92 789108960
0 95 850838250
1 7 708430
1 8 800979960
1 24 529606990
1 25 822365030
1 40 803087030
1 75 339182160
1 79 841073850
1 86 249876300
1 92 93708160
2 6 653731...

output:


result:

wrong answer 1st lines differ - expected: '410099610', found: ''

Subtask #8:

score: 0
Skipped

Dependency #1:

0%