답안 #375978

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
375978 2021-03-10T11:57:38 Z SavicS Ceste (COCI17_ceste) C++14
0 / 160
3 ms 1792 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 = 1e9 + 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){
				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;
}
/**



// probati bojenje sahovski ili slicno

**/


# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 620 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 620 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1516 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1004 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 1792 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 1516 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 1516 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1516 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -