Task: | Tietoverkko |
Sender: | shmoul |
Submission time: | 2021-10-17 22:47:47 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 10 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 10 |
#2 | TIME LIMIT EXCEEDED | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 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:59:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=1;i<Computers.size();i++) ~^~~~~~~~~~~~~~~~~ input/code.cpp:61:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int j=i;j<Computers.size();j++) ~^~~~~~~~~~~~~~~~~
Code
#include <iostream> #include <vector> #include <cmath> using namespace std; struct Connection { int CompID; int Speed; Connection(int compid, int speed) {CompID=compid; Speed=speed;} }; struct Computer { vector<Connection> Connections; Computer(){} }; vector<Computer> Computers; long long SpeedSum; int FindSpeed(int from, int to, int origin=-1) { Computer& c = Computers[from]; int n=0; vector<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); if(s>0) { n=min(conn.Speed, s); break; } //&&(n==0||n>s)) n=fmin(conn.Speed, s); } //c.Connections.push_back(Connection(to, n)); return n; } int main() { 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;j<Computers.size();j++) { int Speed = FindSpeed(j, i); SpeedSum+=Speed; // Computers[j].Connections.push_back(Connection(i, Speed)); // Computers[i].Connections.push_back(Connection(j, Speed)); } } cout<<SpeedSum; return 0; }
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 1 2 74 1 3 100 2 4 50 3 5 40 ... |
correct output |
---|
88687 |
user output |
---|
88687 |
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) |