Submission #952326

# Submission time Handle Problem Language Result Execution time Memory
952326 2024-03-23T14:25:51 Z vjudge306 Relay Marathon (NOI20_relaymarathon) C++17
5 / 100
6000 ms 5844 KB
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define nn "\n"
#define x_x ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define intt int _; cin >> _; while (_--)
#define emp push_back
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define ld long double
#define A first
#define B second
//#define int long long
typedef long long ll;
const ld eps = 1e-27;
// diff between decimals 0.000000001 mt19937 mt(time(nullptr));
struct ed {
int f; int t; ll w;
};
int main() {

    x_x
    int n,k,m; cin>>n>>m>>k; vector<ed>adj;
    for (int i=0,a,b,c; i<m; i++)
    cin>>a>>b>>c, adj.emp({a,b,c}), adj.emp({b,a,c});

    int sp[n+2]={}; ll dis[n+2]; for (int i=0,x;i<k; i++) cin>>x, sp[x]=1;
    vector<ed>v;
    for (int z=1; z<=n; z++) {
        if (!sp[z]) continue;
       for (auto&i:dis)i=1e15;
    dis[z]=0;
       for (int nm=0; nm<=n+2; nm++) {
        for (auto i:adj) {
            if (dis[i.t]>(dis[i.f]+i.w))
                dis[i.t]=(dis[i.f]+i.w);
        }
       }
       for (int i=z+1; i<=n; i++)
       if (sp[i]) v.emp({z,i,dis[i]});
    }
    ll ans=LLONG_MAX;
    for (int i=0; i<v.size(); i++) {
        for (int j=i+1; j<v.size(); j++)
            if (v[i].f!=v[j].f&&v[i].t!=v[j].t&&v[i].f!=v[j].t&&v[i].t!=v[j].f)
            ans=min(ans, v[i].w+v[j].w);
    }
    cout<<ans;
  return 0;
}

Compilation message

RelayMarathon.cpp: In function 'int main()':
RelayMarathon.cpp:46:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<ed>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for (int i=0; i<v.size(); i++) {
      |                   ~^~~~~~~~~
RelayMarathon.cpp:47:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<ed>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for (int j=i+1; j<v.size(); j++)
      |                         ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 6 ms 528 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 8 ms 724 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 4 ms 524 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 3 ms 500 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 6 ms 564 KB Output is correct
29 Correct 3 ms 348 KB Output is correct
30 Correct 5 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 6 ms 528 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 8 ms 724 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 4 ms 524 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 3 ms 500 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 6 ms 564 KB Output is correct
29 Correct 3 ms 348 KB Output is correct
30 Correct 5 ms 348 KB Output is correct
31 Correct 2 ms 344 KB Output is correct
32 Correct 9 ms 344 KB Output is correct
33 Correct 4 ms 348 KB Output is correct
34 Correct 3 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 2448 ms 2004 KB Output is correct
37 Execution timed out 6011 ms 2884 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6021 ms 5844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 6 ms 528 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 8 ms 724 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 4 ms 524 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 3 ms 500 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 6 ms 564 KB Output is correct
29 Correct 3 ms 348 KB Output is correct
30 Correct 5 ms 348 KB Output is correct
31 Correct 2 ms 344 KB Output is correct
32 Correct 9 ms 344 KB Output is correct
33 Correct 4 ms 348 KB Output is correct
34 Correct 3 ms 344 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 2448 ms 2004 KB Output is correct
37 Execution timed out 6011 ms 2884 KB Time limit exceeded
38 Halted 0 ms 0 KB -