QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#876978#2501. Olympic BusWansur#0 8ms8096kbC++231.8kb2025-01-31 16:14:332025-01-31 16:14:34

Judging History

This is the latest submission verdict.

  • [2025-01-31 16:14:34]
  • Judged
  • Verdict: 0
  • Time: 8ms
  • Memory: 8096kb
  • [2025-01-31 16:14:33]
  • Submitted

answer

#include <bits/stdc++.h>
#define ent '\n'
#define int long long

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

typedef long long ll;
using namespace std;

const int maxn = 1e5 + 12;
const int inf = (int)2e9 + (int)1e8;

int cost[202][202];
int u[maxn], v[maxn], w[maxn], c[maxn];
int d1[maxn], dn[maxn];
bool used[maxn];
int n, m, k;

void work(int ver, int d[]) {
    for(int i = 1; i <= n; i++) {
        d[i] = inf;
        used[i] = false;
    }
    d[ver] = 0;
    for(int t = 0; t < n; t++) {
        int v = 0;
        for(int i = 1; i <= n; i++) {
            if((!v || d[i] < d[v]) && !used[i]) {
                v = i;
            }
        }
        if(!v || d[v] == inf) break;
        used[v] = true;
        for(int i = 1; i <= n; i++) {
            if(cost[v][i] < inf) {
                d[i] = min(d[i], d[v] + cost[v][i]);
            }
        }
    }
}

void solve() {
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            cost[i][j] = inf;
        }
        cost[i][i] = 0;
    }
    for(int i = 1; i <= m; i++) {
        cin >> u[i] >> v[i] >> w[i] >> c[i];
        cost[u[i]][v[i]] = w[i];
    }
    work(1, d1);
    work(n, dn);
    int ans = d1[n] + dn[1];
    for(int i = 1; i <= m; i++) {
        int dist1 = d1[n], distn = dn[1];
        dist1 = min(dist1, d1[v[i]] + dn[u[i]] + w[i]);
        distn = min(distn, dn[v[i]] + d1[u[i]] + w[i]);
        ans = min(ans, dist1 + distn + c[i]);
    }
    cout << ans << ent;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 5
Accepted
time: 1ms
memory: 6012kb

input:

200 1000
122 152 0 182437847
22 126 0 800796216
142 158 0 932784437
27 61 0 220600502
2 106 0 369508879
150 200 0 576962057
99 9 0 588062163
101 72 0 148003923
9 182 0 732139947
84 88 0 720592694
198 161 0 151363245
89 187 0 214138025
160 150 0 82621350
63 170 0 665493133
135 144 0 571301198
118 29 ...

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 7968kb

input:

200 250
87 77 0 413690178
44 146 0 580238372
96 86 0 471635629
76 37 0 460314897
36 26 0 797795878
186 196 0 340458462
137 148 0 8238512
63 102 0 83585569
128 92 0 355539314
111 136 0 941271932
120 25 0 670904911
68 143 0 789757256
50 24 0 57273302
166 33 0 961114401
151 122 0 88660198
162 71 0 2027...

output:

4200000000

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 8ms
memory: 8096kb

input:

200 50000
92 72 987034 981351
92 72 987034 428035
95 16 263441 869630
95 16 263441 274419
18 67 742896 495941
18 67 742896 773584
89 7 456457 702434
89 7 456457 631522
52 193 188333 207969
52 193 188333 151198
32 144 801401 523873
32 144 801401 485433
114 30 945638 685397
114 30 945638 387101
177 94...

output:

87888

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #31:

score: 21
Accepted
time: 0ms
memory: 6056kb

input:

200 1000
29 42 0 73206665
155 127 0 684640269
50 198 0 321195054
144 61 0 823740117
102 146 0 503128895
56 38 0 739648322
181 24 0 720383720
197 37 0 235418116
57 184 0 493283302
125 96 0 845930225
11 59 0 18751364
101 122 0 175819721
123 151 0 99670888
111 194 0 526645991
132 64 0 904239661
103 173...

output:

0

result:

ok single line: '0'

Test #32:

score: 0
Wrong Answer
time: 0ms
memory: 6056kb

input:

200 250
72 162 0 953534115
152 94 0 541492633
58 118 0 389246378
118 137 0 266112508
21 100 0 546059320
26 28 0 396924657
155 69 0 955241958
123 102 0 483117471
160 39 0 787307136
31 80 0 230131728
33 69 0 459221426
149 126 0 356240138
128 99 0 991905541
7 57 0 28752914
149 6 0 761950451
23 150 0 66...

output:

983840898

result:

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

Subtask #4:

score: 0
Skipped

Dependency #1:

0%