Submission #517034

#TimeUsernameProblemLanguageResultExecution timeMemory
517034aurimsFire drill (LMIO18_sauga)C++14
10 / 100
218 ms6308 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...