Submission #1074437

# Submission time Handle Problem Language Result Execution time Memory
1074437 2024-08-25T10:31:50 Z cpptowin Ceste (COCI17_ceste) C++17
96 / 160
175 ms 2260 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 3010
#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;
        minimize(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 0 ms 348 KB Output is correct
# 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 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 1368 KB Output is correct
2 Correct 42 ms 2256 KB Output is correct
3 Correct 54 ms 2260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 136 ms 2248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 1044 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 175 ms 1184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 163 ms 2252 KB Output is correct
2 Incorrect 146 ms 2252 KB Output isn't correct
3 Halted 0 ms 0 KB -