Submission #952344

# Submission time Handle Problem Language Result Execution time Memory
952344 2024-03-23T15:14:20 Z vjudge306 Fuel Station (NOI20_fuelstation) C++17
0 / 100
829 ms 1048576 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));

int main() {

    x_x
    int n,K; cin>>n>>K; ll dis[n+2][n+2];
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) dis[i][j]=1e15;
    }
    for (int i=1,a,b,c; i<n; i++) cin>>a>>b>>c, dis[a][b]=c, dis[b][a]=c;
    int nm=(1<<n); int f[n+2]={}; ll d[n+2][n+2];
    vector<int>ans;
    for (int i=1; i<=n; i++) ans.emp(i);

    for (int z=1; z<nm; z++) {

        for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
           d[i][j]=dis[i][j];
        }
    }
    int in=0;
        for (int i=0; i<n; i++) {
            if (z&(1<<i)) f[i+1]=1, d[i+1][i+1]=0, in++; else f[i+1]=0;
        }
        for (int k=1; k<=n; k++) {
            for (int i=1; i<=n; i++) {
                for (int j=1; j<=n; j++) d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    bool ok=1;
    for (int i=1; i<=n; i++) {
        ll mn=LLONG_MAX;
        for (int j=1; j<=n; j++) {
            if (f[j])mn=min(mn, d[i][j]);
        }
        if(mn>K) {ok=0; break;}
    }
    if(ok&&in<ans.size()) {
        ans.clear(); for(int i=1; i<=n; i++) if (f[i]) ans.emp(i);
    }
    }
    cout<<ans.size()<<nn;
    for(auto i:ans)cout<<i<<' ';
  return 0;
}

Compilation message

FuelStation.cpp: In function 'int main()':
FuelStation.cpp:57:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     if(ok&&in<ans.size()) {
      |            ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 829 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -