108392024-04-16 12:47:25abelke2Áruszállítás (75 pont)cpp17Wrong answer 51/75400ms15772 KiB
#include <iostream>
#include <vector>

#define ull unsigned long long

using namespace std;

int main()
{
	int noOfStations = 0;
	int noOfRoutes = 0;
	cin >> noOfStations >> noOfRoutes;
	vector<int> statVector(noOfStations + 1);
	
	int start = 0;
	int stop = 0;
	for (int i = 0; i < noOfRoutes; ++i)
	{
		cin >> start >> stop;
		if (start == stop - 1)
		{
			statVector[start] = 3;
			statVector[stop] = 3;
		}
		else
		{
			if (statVector[start] != 1)
			{
				statVector[start] = 2;
			}
			for (int j = start + 1; j < stop; ++j)
			{
				statVector[j] = 1;
			}
			if (statVector[stop] != 1)
			{
				statVector[stop] = 2;
			}
		}
	}

	/*for (int i = 1; i <= noOfStations; ++i)
	{
		cout << statVector[i] << " ";
	}
	cout << "\n";
	for (int i = 1; i <= noOfStations; ++i)
	{
		cout << i << " ";
	}*/

	int result = 0;
	for (int i = 1; i < noOfStations; ++i)
	{
		if((statVector[i] == 2 && statVector[i + 1] == 0) 
					|| (statVector[i] == 0 && statVector[i + 1] == 2)
					|| (statVector[i] == 0 && statVector[i + 1] == 0)
					|| (statVector[i] == 2 && statVector[i + 1] == 2)
					|| (statVector[i] == 3 && statVector[i + 1] == 0)
					|| (statVector[i] == 0 && statVector[i + 1] == 3))
		{
			++result;
		}
	}
	cout << result;

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base51/75
1Accepted0/03ms1956 KiB
2Accepted0/090ms11388 KiB
3Accepted3/33ms3732 KiB
4Accepted3/33ms3868 KiB
5Accepted3/33ms4112 KiB
6Accepted3/33ms4192 KiB
7Accepted3/33ms4304 KiB
8Accepted4/43ms4168 KiB
9Accepted4/43ms4304 KiB
10Accepted4/43ms4300 KiB
11Accepted4/43ms4620 KiB
12Accepted4/43ms5016 KiB
13Wrong answer0/47ms5296 KiB
14Wrong answer0/48ms5988 KiB
15Wrong answer0/47ms6380 KiB
16Time limit exceeded0/4400ms5616 KiB
17Time limit exceeded0/4365ms5820 KiB
18Time limit exceeded0/4372ms6432 KiB
19Accepted4/49ms8412 KiB
20Accepted4/412ms9512 KiB
21Accepted4/476ms14560 KiB
22Accepted4/479ms15772 KiB