제출 #1135555

#제출 시각아이디문제언어결과실행 시간메모리
1135555PwoKOVANICE (COI15_kovanice)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n, m, q, p[300005], sz[300005], ans[300005]; vector<int> g[300005], topo; bool visited[300005], z[300005]; int find(int v) { if (p[v] == v) return v; return p[v] = find(p[v]); } void merge(int u, int v) { u = find(u), v = find(v); if (u == v) return; if (sz[v] < sz[u]) swap(u, v); p[u] = v; sz[v] += sz[u]; } void dfs(int v) { visited[v] = 1; for (const int u : g[v]) if (!visited[u]) dfs(u); topo.push_back(v); } int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> m >> q; for (int i = 1; i <= m; i++) p[i] = i, sz[i] = 1; while (q--) { char c; int a, b; string s; cin >> s; stringstream os(s); os >> a >> c >> b; if (c == '=') merge(a, b); else g[a].push_back(b), z[b] = 1; } for (int i = 1; i <= m; i++) { if (z[i] || visited[i]) continue; topo.clear(); dfs(i); assert((int) topo.size <= n); if ((int) topo.size() >= n) { for (size_t j = 0; j < topo.size(); j++) ans[find(topo[j])] = n - j; } } for (int i = 1; i <= m; i++) { int res = ans[find(i)]; if (res == 0) cout << "?\n"; else cout << 'K' << res << '\n'; } }

컴파일 시 표준 에러 (stderr) 메시지

In file included from /usr/include/c++/11/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:33,
                 from kovanice.cpp:1:
kovanice.cpp: In function 'int32_t main()':
kovanice.cpp:45:35: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' (did you forget the '()' ?)
   45 |                 assert((int) topo.size <= n);
      |                              ~~~~~^~~~