# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
114292 | MohamedAhmed04 | Ceste (COCI17_ceste) | C++14 | 2577 ms | 512 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2010 ;
struct edge
{
int to , time , cost ;
edge(int ve , int ti , int co)
{
to = ve ;
time = ti ;
cost = co ;
}
};
vector< vector<edge> >adj(MAX) ;
int vis[MAX] ;
int n , m ;
long long ans[MAX] ;
void dfs(int node , int sumt , int sumc)
{
ans[node] = min(ans[node] , (sumt * 1ll) * (sumc * 1ll)) ;
for(auto &child : adj[node])
{
if(vis[child.to] == 1)
continue ;
vis[child.to] = 1 ;
dfs(child.to , sumt + child.time , sumc + child.cost) ;
vis[child.to] = 0 ;
}
return ;
}
int main()
{
scanf("%d %d" , &n , &m) ;
int a , b , c , d ;
for(int i = 0 ; i < m ; ++i)
{
scanf("%d %d %d %d" , &a , &b , &c , &d) ;
adj[a].push_back(edge(b , c , d)) ;
adj[b].push_back(edge(a , c , d)) ;
}
long long cons = 1e18 ;
for(int i = 1 ; i <= n ; ++i)
ans[i] = cons ;
dfs(1 , 0 , 0) ;
for(int i = 2 ; i <= n ; ++i)
{
if(ans[i] == cons)
ans[i] = -1 ;
printf("%lld\n" , ans[i]);
}
return 0 ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |