daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. int n, m = 0;
  8. long long dp[10001][2];
  9. bool used[10000];
  10. vector <vector<long long>> cost;
  11. vector <vector<int>> edge;
  12. vector <vector<int>> type;
  13.  
  14. int main()
  15. {
  16.     cin >> n >> m;
  17.     cost.resize(n);
  18.     edge.resize(n);
  19.     type.resize(n);
  20.     for (int i = 0; i < m; i++) {
  21.         string str;
  22.         int tpn, tptw, cst;
  23.         cin >> tpn >> tptw >> cst >> str;
  24.         if (str[0] == 'L') {
  25.             type[tptw - 1].push_back(0);
  26.         }
  27.         if (str[0] == 'P') {
  28.             type[tptw - 1].push_back(1);
  29.         }
  30.         if (str[0] == 'C') {
  31.             type[tptw - 1].push_back(2);
  32.         }
  33.         edge[tptw - 1].push_back(tpn - 1);
  34.         cost[tptw - 1].push_back(cst);
  35.     }
  36.     used[0] = true;
  37.     for (int i = 0; i < n; i++) {
  38.         used[i + 1] = false;
  39.         for (int k = 0; k < edge[i].size(); k++) {
  40.             if (used[edge[i][k]] == true && (type[i][k] == 0 || type[i][k] == 2)) {
  41.                 used[i] = true;
  42.             }
  43.         }
  44.         long long min = 100000000000ll;
  45.         for (int k = 0; k < edge[i].size(); k++) {
  46.             if (used[edge[i][k]] == true && used[i] == true){
  47.                 if (min > dp[edge[i][k]][0] + cost[i][k]) {
  48.                     min = dp[edge[i][k]][0] + cost[i][k];
  49.                 }
  50.             }
  51.         }
  52.         dp[i][0] = min;
  53.         if (dp[i][0] == 100000000000ll) {
  54.             dp[i][0] = 0;
  55.         }
  56.     }
  57.    
  58.     for (int i = 0; i < n; i++) {
  59.         for (int k = 0; k < edge[i].size(); k++) {
  60.     }
  61. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top