Submission #498615

# Submission time Handle Problem Language Result Execution time Memory
498615 2021-12-25T19:17:24 Z aurims Cheap flights (LMIO18_pigus_skrydziai) C++14
0 / 100
106 ms 262148 KB
#include <bits/stdc++.h>
#define pb push_back
#define MAXN 5000
using namespace std;

/* 
input
5 4
1 2 1
1 3 2
1 4 1
2 4 1
*/

struct miestas
{
	vector<int> kaimynai;
	vector<int> pelnas;
};
vector<miestas> miestai;

int rask_didz_pelna(int idx)
{
	int pelnas = 0;

	for(int kaim : miestai[idx].kaimynai)
	{

	}

	return pelnas;
}

int main()
{
	//int m1[MAXN][MAXN];
	int N, M;
	cin >> N >> M;
	/*
	for(int i = 0; i < N; i++)
	{
		for(int j = 0; j < N; j++)
		{
			m1[i][j] = -1;
		}
	}
	*/
	miestai.resize(N);
	for(int i = 0; i < N; i++)
		miestai[i].pelnas.resize(N);
	for(int i = 0; i < M; i++)
	{
		int a, b, p;
		cin >> a >> b >> p;
		miestai[a-1].kaimynai.pb(b-1);
		miestai[b-1].kaimynai.pb(a-1);
		miestai[a-1].pelnas[b-1] = p;
		miestai[b-1].pelnas[a-1] = p;
		/*
		m1[a-1][b-1] = p;
		m1[b-1][a-1] = p;
		*/
	}
	int mx = -1;
	// perrenkam visas zvaigzdes
	for(int i = 0; i < N; i++)
	{
		int sum = 0;
		for(int sidx : miestai[i].kaimynai)
		{
			sum += miestai[i].pelnas[sidx];
		}
		if(sum > mx)
			mx = sum;
	}
	cout << mx << '\n';
}

/*
zvaigzdziu perrinkimas:
iteruojam per visas grafo virsunes ir sudedam ju briaunu svorius

trikampiu perrinkimas:

*/

Compilation message

pigus_skrydziai.cpp: In function 'int rask_didz_pelna(int)':
pigus_skrydziai.cpp:26:10: warning: unused variable 'kaim' [-Wunused-variable]
   26 |  for(int kaim : miestai[idx].kaimynai)
      |          ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 292 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 292 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 106 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 106 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -