Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cstring>
  3. #include <algorithm>
  4. #include <vector>
  5. #include <iostream>
  6. #include <cassert>
  7. #include <cmath>
  8. #include <string>
  9. #include <queue>
  10. #include <set>
  11. #include <map>
  12. #include <cstdlib>
  13. #include <fstream>
  14.  
  15. using namespace std;
  16.  
  17. struct connectionInfo {
  18. int cacheNumber;
  19. int latency;
  20. };
  21.  
  22. struct endPointInfo {
  23. int centerLat;
  24.  
  25. vector< connectionInfo > connections;
  26. };
  27.  
  28. struct requestInfo {
  29. int video;
  30. int endpoint;
  31. int requests;
  32. };
  33.  
  34. int videosCount;
  35. int endPointsCount;
  36. int requestsCount;
  37. int cachesCount;
  38. int cacheSize;
  39. vector<int> videoSizes;
  40. vector<endPointInfo> endPoints;
  41. vector<requestInfo> requests;
  42.  
  43. vector< vector<int> > cacheToVideo;
  44. vector< vector<int> > videoToCache;
  45.  
  46. void readData( ifstream& input) {
  47. input >> videosCount >> endPointsCount >> requestsCount >> cachesCount >> cacheSize;
  48. for (int i = 0; i < videosCount; i++) {
  49. int videoSize;
  50. input >> videoSize;
  51. videoSizes.push_back(videoSize);
  52. }
  53. for (int i = 0; i < endPointsCount; i++) {
  54. endPointInfo info;
  55. int connectionsCount;
  56. input >> info.centerLat >> connectionsCount;
  57. for (int j = 0; j < connectionsCount; j++) {
  58. connectionInfo connection;
  59. input >> connection.cacheNumber >> connection.latency;
  60. info.connections.push_back(connection);
  61. }
  62. }
  63. for (int i = 0; i < requestsCount; i++) {
  64. requestInfo request;
  65. input >> request.video >> request.endpoint >> request.requests;
  66. requests.push_back(request);
  67. }
  68. }
  69.  
  70. void writeAnswer(ofstream &output) {
  71. output << result.size() << endl;
  72. for (int i = 0; i < result.size(); i++) {
  73.  
  74. output << i << " ";
  75. for (int j = 0; j < result[i].size(); j++) {
  76. output << result[i][j] << " ";
  77. }
  78. output << endl;
  79. }
  80. }
  81.  
  82. void calcVideoToCache() {
  83. videoToCache.assign(videosCount, std::vector<int>());
  84. for (int i = 0; i < cacheToVideo.size(); i++) {
  85. for (int j = 0; j < cacheToVideo[i].size(); j++) {
  86. int video = cacheToVideo[i][j];
  87. videoToCache[video].push_back(i);
  88. }
  89. }
  90. }
  91.  
  92. long long calculate() {
  93. calcVideoToCache();
  94. for (int i = 0; i < requestsCount; i++) {
  95. requestInfo& request = requests[i];
  96. int video = request.video;
  97. int endPoint = request.endpoint;
  98. vector<int>& caches = videoToCache[video];
  99. for (int j = 0; j < caches.size(); j++) {
  100. int cache =
  101. }
  102. }
  103. }
  104.  
  105. int main() {
  106. ios_base::sync_with_stdio(false);
  107. cin.tie(nullptr);
  108. cout.setf(ios::fixed);
  109. cout.precision(9);
  110. cerr.setf(ios::fixed);
  111. cerr.precision(3);
  112.  
  113. vector<string> files;
  114. files.push_back("kittens");
  115. files.push_back("me_at_the_zoo");
  116. files.push_back("trending_today");
  117. files.push_back("videos_worth_spreading");
  118.  
  119. for (int i = 0; i < files.size(); i++) {
  120. ifstream input;
  121. ofstream output;
  122. input.open(files[i] + ".in");
  123. output.open(files[i] + ".out");
  124. readData(input);
  125. }
  126. freopen("test.in", "r", stdin);
  127. freopen("test.out", "w", stdout);
  128.  
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement