Submission #1074443

# Submission time Handle Problem Language Result Execution time Memory
1074443 2024-08-25T10:33:22 Z cpptowin Ceste (COCI17_ceste) C++17
96 / 160
175 ms 2284 KB
#include <bits/stdc++.h>
#define fo(i, d, c) for (int i = d; i <= c; i++)
#define fod(i, c, d) for (int i = c; i >= d; i--)
#define maxn 1000010
#define N 5010
#define fi first
#define se second
#define pb emplace_back
#define en cout << "\n";
#define bitcount(x) __builtin_popcountll(x)
#define pii pair<int, int>
#define vii vector<pii>
#define lb(x) x & -x
#define bit(i, j) ((i >> j) & 1)
#define offbit(i, j) (i ^ (1LL << j))
#define onbit(i, j) (i | (1LL << j))
#define vi vector<int>
#define all(x) x.begin(), x.end()
#define ss(x) (int)x.size()
template <typename T1, typename T2>
bool minimize(T1 &a, T2 b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
bool maximize(T1 &a, T2 b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
using namespace std;
const int nsqrt = 450;
const int mod = 1e9 + 7;
void add(int &x, int k)
{
    x += k;
    x %= mod;
    if(x < 0) x += mod;
}
void del(int &x, int k)
{
    x -= k;
    x %= mod;
    if(x < 0) x += mod;
}
int n,m;
long long minf[N],mint[N];
vector<array<int,3>> ke[N];
main()
{
#define name "TASK"
    if (fopen(name ".inp", "r"))
    {
        freopen(name ".inp", "r", stdin);
        freopen(name ".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    fo(i,1,m) 
    {
        int u,v,t,c;
        cin >> u >> v >> t >> c;
        ke[u].push_back({v,t,c});
        ke[v].push_back({u,t,c});
    }
    priority_queue<array<int,3>,vector<array<int,3>>,greater<array<int,3>>>q;
    fo(i,2,n) minf[i] = mint[i] = 1e18;
    q.push({0,0,1});
    int lim = 2000 * 3000;
    while(ss(q))
    {
        auto [du,dt,u] = q.top();
        minimize(minf[u],du * dt);
        q.pop();
        if(mint[u] < dt) continue;
        mint[u] = dt;
        for(auto [v,t,c] : ke[u]) 
        {
            if(dt + t <= lim) q.push({du + c,dt + t,v});
        }
    }
    fo(i,2,n) cout << (minf[i] >= 1e18 ? -1 : minf[i]) << '\n';
}

Compilation message

ceste.cpp:58:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   58 | main()
      | ^~~~
ceste.cpp: In function 'int main()':
ceste.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen(name ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ceste.cpp:64:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         freopen(name ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1364 KB Output is correct
2 Correct 48 ms 2256 KB Output is correct
3 Correct 57 ms 2260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 132 ms 2284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 1048 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 175 ms 1040 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 156 ms 2260 KB Output is correct
2 Incorrect 143 ms 2260 KB Output isn't correct
3 Halted 0 ms 0 KB -