Task: | Tietoverkko |
Sender: | shmoul |
Submission time: | 2021-10-17 23:19:11 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#2 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:67:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=1;i<Computers.size();i++) ~^~~~~~~~~~~~~~~~~ input/code.cpp:69:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int j=i+1;j<Computers.size();j++) ~^~~~~~~~~~~~~~~~~
Code
#include <iostream> #include <vector> #include <list> #include <cmath> #include <map> using namespace std; struct Connection { int CompID; int Speed; Connection(int compid, int speed) {CompID=compid; Speed=speed;} }; struct Computer { list<Connection> Connections; Computer(){} }; vector<Computer> Computers; long long SpeedSum; map<long long, int> ConnectionCache; int FindSpeed(int from, int to, int origin=-1) { auto x = ConnectionCache.find(((long long)from<<32)|to); if(x!=ConnectionCache.end()) return x->second; Computer& c = Computers[from]; int n=0; list<Connection> temp = c.Connections; for(Connection& conn : c.Connections) { if(origin==conn.CompID) continue; if(conn.CompID==to) return conn.Speed; int s = FindSpeed(conn.CompID, to, from); ConnectionCache[((long long)conn.CompID<<32)|to]=s; if(s>0) { n=min(conn.Speed, s); break; } } //ConnectionCache[((long long)from<<32)|to]=n; return n; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); int count; cin>>count; for(int i=0;i<=count;i++) { Computers.push_back(Computer()); } for(int i=1;i<count;i++) { int compid1, compid2, speed; cin>>compid1>>compid2>>speed; Computer& comp1 = Computers[compid1]; Computer& comp2 = Computers[compid2]; comp1.Connections.push_back(Connection(compid2, speed)); comp2.Connections.push_back(Connection(compid1, speed)); } for(int i=1;i<Computers.size();i++) { for(int j=i+1;j<Computers.size();j++) { int Speed = FindSpeed(j, i); SpeedSum+=Speed; //Computers[j].Connections.push_front(Connection(i, Speed)); //Computers[i].Connections.push_front(Connection(j, Speed)); } } cout<<SpeedSum; return 0; }
Test details
Test 1
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
100 1 2 74 1 3 100 2 4 50 3 5 40 ... |
correct output |
---|
88687 |
user output |
---|
62287 |
Test 2
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
5000 1 2 613084013 1 3 832364259 2 4 411999902 3 5 989696303 ... |
correct output |
---|
1103702320243776 |
user output |
---|
(empty) |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 1 2 613084013 1 3 832364259 2 4 411999902 3 5 989696303 ... |
correct output |
---|
1080549209850010931 |
user output |
---|
(empty) |