Submission #375980

# Submission time Handle Problem Language Result Execution time Memory
375980 2021-03-10T12:00:16 Z SavicS Ceste (COCI17_ceste) C++14
0 / 160
3 ms 1516 KB
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define fb(i,b,a) for(int i=b;i>=a;i--)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 105;
const ll inf = 1e14 + 5;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// os.order_of_key(k) the number of elements in the os less than k
// *os.find_by_order(k)  print the k-th smallest number in os(0-based)

int n, m;

ll dp[maxn][maxn][2];
ll ukdp[maxn][maxn];

int main()
{
   	ios::sync_with_stdio(false);
   	cout.tie(nullptr);
  	cin.tie(nullptr);
	cin >> n >> m;
	ff(i,1,n){
		ff(j,1,n){
			dp[i][j][0] = dp[i][j][1] = ukdp[i][j] = inf;
		}
	}
	ff(i,1,m){
		int u, v, w, c;
		cin >> u >> v >> w >> c;
		dp[u][v][0] = w;
		dp[u][v][1] = c;
		dp[v][u][0] = w;
		dp[v][u][1] = c;
		ukdp[u][v] = w * c;
		ukdp[v][u] = w * c;
	}
	ff(k,1,n){
		ff(i,1,n){
			ff(j,1,n){
				if(dp[i][k][0] == inf || dp[k][j][0] == inf)continue;
				ll a = dp[i][k][0] + dp[k][j][0];
				ll b = dp[i][k][1] + dp[k][j][1];
				if((ll)(a * b) < ukdp[i][j]){
					ukdp[i][j] = a * b;
					dp[i][j][0] = a;
					dp[i][j][1] = b;
				}
			}
		}
	}
	ff(i,2,n)cout << (ukdp[1][i] == inf ? -1 : ukdp[1][i]) << endl;
   	return 0;
}
/**

4 4
1 2 2 4
3 4 4 1
4 2 1 1
1 3 3 1


// probati bojenje sahovski ili slicno

**/


# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 620 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 620 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1516 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1004 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1516 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1516 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 1516 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1516 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -