Submission #517034

# Submission time Handle Problem Language Result Execution time Memory
517034 2022-01-22T12:24:13 Z aurims Fire drill (LMIO18_sauga) C++14
10 / 100
218 ms 6308 KB
#include <array>
#include <list>
#include <iostream>
#include <vector>
#define debug cout << "alion\n"
#define MAX (int)10e3
#define pb push_back
using namespace std;

void test_print(vector<vector<int>> l)
{
	for(int i = 0; i < l.size(); i++)
	{
		cout << "City " << i << ".\n";
		for(int j = 0; j < l[i].size(); j++)
			cout << l[i][j] << ' ';
		cout << '\n';
	}
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	int T, N, S;
	cin >> T >> N >> S;
	vector<vector<int>> l(N);
	for(int i = 0; i < N; i++)
	{
		int n;
		cin >> n;
		l[i].resize(n);
		for(int j = 0; j < n; j++)
		{
			cin >> l[i][j];
			l[i][j]--;
		}
	}
	vector<int> evac;
	int i = 0;
	while(evac.size() < N)
	{
		if(l[i].empty()) // if node has no outgoing edges
		{
			evac.pb(i); // it can be evacuated freely with no penalties
			// delete it from graph
			for(int j = 0; j < N; j++)
			{
				if(j == i) continue;
				for(int k = 0; k < l[j].size(); k++)
					if(l[j][k] == i)
						l[j].erase(l[j].begin()+k);
			}
			l[i] = {-1};
			i = -1;
		}
		i++;
	}
	for(const int idx : evac)
		cout << idx+1 << '\n';
}

Compilation message

sauga.cpp: In function 'void test_print(std::vector<std::vector<int> >)':
sauga.cpp:12:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(int i = 0; i < l.size(); i++)
      |                 ~~^~~~~~~~~~
sauga.cpp:15:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   for(int j = 0; j < l[i].size(); j++)
      |                  ~~^~~~~~~~~~~~~
sauga.cpp: In function 'int main()':
sauga.cpp:41:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |  while(evac.size() < N)
      |        ~~~~~~~~~~~~^~~
sauga.cpp:50:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int k = 0; k < l[j].size(); k++)
      |                    ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 218 ms 4336 KB Output is correct
2 Runtime error 3 ms 516 KB Execution killed with signal 11
3 Runtime error 2 ms 560 KB Execution killed with signal 11
4 Runtime error 1 ms 592 KB Execution killed with signal 11
5 Runtime error 1 ms 464 KB Execution killed with signal 11
6 Runtime error 1 ms 592 KB Execution killed with signal 11
7 Runtime error 6 ms 1352 KB Execution killed with signal 11
8 Runtime error 33 ms 6308 KB Execution killed with signal 11
9 Runtime error 8 ms 1096 KB Execution killed with signal 11
10 Runtime error 1 ms 572 KB Execution killed with signal 11