Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cstring>
- #include <algorithm>
- #include <vector>
- #include <iostream>
- #include <cassert>
- #include <cmath>
- #include <string>
- #include <queue>
- #include <set>
- #include <map>
- #include <cstdlib>
- #include <fstream>
- using namespace std;
- struct connectionInfo {
- int cacheNumber;
- int latency;
- };
- struct endPointInfo {
- int centerLat;
- vector< connectionInfo > connections;
- };
- struct requestInfo {
- int video;
- int endpoint;
- int requests;
- };
- int videosCount;
- int endPointsCount;
- int requestsCount;
- int cachesCount;
- int cacheSize;
- vector<int> videoSizes;
- vector<endPointInfo> endPoints;
- vector<requestInfo> requests;
- vector< vector<int> > cacheToVideo;
- vector< vector<int> > videoToCache;
- void readData( ifstream& input) {
- input >> videosCount >> endPointsCount >> requestsCount >> cachesCount >> cacheSize;
- for (int i = 0; i < videosCount; i++) {
- int videoSize;
- input >> videoSize;
- videoSizes.push_back(videoSize);
- }
- for (int i = 0; i < endPointsCount; i++) {
- endPointInfo info;
- int connectionsCount;
- input >> info.centerLat >> connectionsCount;
- for (int j = 0; j < connectionsCount; j++) {
- connectionInfo connection;
- input >> connection.cacheNumber >> connection.latency;
- info.connections.push_back(connection);
- }
- }
- for (int i = 0; i < requestsCount; i++) {
- requestInfo request;
- input >> request.video >> request.endpoint >> request.requests;
- requests.push_back(request);
- }
- }
- void writeAnswer(ofstream &output) {
- output << result.size() << endl;
- for (int i = 0; i < result.size(); i++) {
- output << i << " ";
- for (int j = 0; j < result[i].size(); j++) {
- output << result[i][j] << " ";
- }
- output << endl;
- }
- }
- void calcVideoToCache() {
- videoToCache.assign(videosCount, std::vector<int>());
- for (int i = 0; i < cacheToVideo.size(); i++) {
- for (int j = 0; j < cacheToVideo[i].size(); j++) {
- int video = cacheToVideo[i][j];
- videoToCache[video].push_back(i);
- }
- }
- }
- long long calculate() {
- calcVideoToCache();
- for (int i = 0; i < requestsCount; i++) {
- requestInfo& request = requests[i];
- int video = request.video;
- int endPoint = request.endpoint;
- vector<int>& caches = videoToCache[video];
- for (int j = 0; j < caches.size(); j++) {
- int cache =
- }
- }
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.setf(ios::fixed);
- cout.precision(9);
- cerr.setf(ios::fixed);
- cerr.precision(3);
- vector<string> files;
- files.push_back("kittens");
- files.push_back("me_at_the_zoo");
- files.push_back("trending_today");
- files.push_back("videos_worth_spreading");
- for (int i = 0; i < files.size(); i++) {
- ifstream input;
- ofstream output;
- input.open(files[i] + ".in");
- output.open(files[i] + ".out");
- readData(input);
- }
- freopen("test.in", "r", stdin);
- freopen("test.out", "w", stdout);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement