Submission #215930

#TimeUsernameProblemLanguageResultExecution timeMemory
215930SamAndFire drill (LMIO18_sauga)C++17
57.52 / 100
800 ms3064 KiB
#include <bits/stdc++.h> using namespace std; #define m_p make_pair const int N = 1003; mt19937 rnd(3141); int tt, n, ss; vector<int> a[N]; int u[N]; int q; vector<int> v; bool c[N]; void dfs(int x) { bool z = false; c[x] = true; for (int i = 0; i < a[x].size(); ++i) { int h = a[x][i]; if (!c[h]) dfs(h); else z = true; } if (z) ++q; v.push_back(x); } int ansq; vector<int> ans; int main() { scanf("%d%d%d", &tt, &n, &ss); for (int i = 1; i <= n; ++i) { int q; scanf("%d", &q); while (q--) { int x; scanf("%d", &x); a[i].push_back(x); } } for (int i = 1; i <= n; ++i) u[i] = i; while ((double)clock() / CLOCKS_PER_SEC < 0.8) { for (int i = n; i >= 1; --i) { swap(u[i], u[rnd() % n + 1]); } memset(c, false, sizeof c); v.clear(); q = 0; for (int i = 1; i <= n; ++i) { int x = u[i]; if (!c[x]) dfs(x); } if (ans.empty() || q < ansq) { ans = v; ansq = q; } } for (int i = 0; i < n; ++i) printf("%d\n", ans[i]); return 0; }

Compilation message (stderr)

sauga.cpp: In function 'void dfs(int)':
sauga.cpp:20:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a[x].size(); ++i)
                     ~~^~~~~~~~~~~~~
sauga.cpp: In function 'int main()':
sauga.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &tt, &n, &ss);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sauga.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &q);
         ~~~~~^~~~~~~~~~
sauga.cpp:46:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &x);
             ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...