CSES - Datatähti 2022 alku - Results
Submission details
Task:Tietoverkko
Sender:shmoul
Submission time:2021-10-17 22:51:30 +0300
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.34 s1, 2, 3details
#20.30 s2, 3details
#3--3details

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: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 <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+1;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:

input
100
1 2 74
1 3 100
2 4 50
3 5 40
...

correct output
88687

user output
(empty)

Test 2

Group: 2, 3

Verdict:

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:

input
200000
1 2 613084013
1 3 832364259
2 4 411999902
3 5 989696303
...

correct output
1080549209850010931

user output
(empty)