Submission #215953

#TimeUsernameProblemLanguageResultExecution timeMemory
215953SamAndFire drill (LMIO18_sauga)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define m_p make_pair const int N = 1003; mt19937 rnd(132143134); int tt, n, ss; vector<int> a[N], b[N]; int u[N]; vector<int> v; bool c[N]; void dfs(int x) { c[x] = true; for (int i = 0; i < a[x].size(); ++i) { int h = a[x][i]; if (!c[h]) dfs(h); } v.push_back(x); } void dfs1(int x) { c[x] = true; v.push_back(x); for (int i = 0; i < b[x].size(); ++i) { int h = b[x][i]; if (!c[h]) dfs(h); } } 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); b[x].push_back(i); } } 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() % i) + 1]); } for (int i = 1; i <= n; ++i) { for (int j = (int)b[i].size() - 1; j >= 0; --j) { swap(b[i][j], b[i][rnd() % (j + 1)]); } for (int j = (int)a[i].size() - 1; j >= 0; --j) { swap(a[i][j], a[i][rnd() % (j + 1)]); } } memset(c, false, sizeof c); v.clear(); for (int i = 1; i <= n; ++i) { int x = u[i]; if (!c[x]) { if (rnd() % 2 == 0) dfs1(x); else dfs2(x); } } memset(c, false, sizeof c); int q = 0; for (int i = 0; i < n; ++i) { int x = v[i]; for (int j = 0; j < a[x].size(); ++j) { int h = a[x][j]; if (!c[h]) { ++q; break; } } c[x] = true; } 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:18:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a[x].size(); ++i)
                     ~~^~~~~~~~~~~~~
sauga.cpp: In function 'void dfs1(int)':
sauga.cpp:31:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < b[x].size(); ++i)
                     ~~^~~~~~~~~~~~~
sauga.cpp: In function 'int main()':
sauga.cpp:86:21: error: 'dfs2' was not declared in this scope
                     dfs2(x);
                     ^~~~
sauga.cpp:86:21: note: suggested alternative: 'dfs1'
                     dfs2(x);
                     ^~~~
                     dfs1
sauga.cpp:94:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j = 0; j < a[x].size(); ++j)
                             ~~^~~~~~~~~~~~~
sauga.cpp:44: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:48:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &q);
         ~~~~~^~~~~~~~~~
sauga.cpp:52:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &x);
             ~~~~~^~~~~~~~~~