diff --git a/NFLSOJ/0/3692/3692.cpp b/NFLSOJ/0/3692/3692.cpp new file mode 100644 index 00000000..b1ed9f65 --- /dev/null +++ b/NFLSOJ/0/3692/3692.cpp @@ -0,0 +1,67 @@ +#include +#include +#include +#include +#include + +// using std::cin; +// using std::cout; +std::ifstream cin("graph.in"); +std::ofstream cout("graph.out"); +const char endl = '\n'; + +const int N = 1e5 + 5; + +int n, m, d[N], ans; +std::vector g[N]; +std::priority_queue, std::vector>, std::greater<>> q; +bool vis[N]; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n >> m; + + for (int i = 1, x, y; i <= m; ++i) { + cin >> x >> y; + + g[x].emplace_back(y); + g[y].emplace_back(x); + d[x]++, d[y]++; + } + + ans = *std::min_element(d + 1, d + 1 + n); + + for (int i = 1; i <= n; i++) { + q.emplace(d[i], i); + } + + while (!q.empty()) { + auto o = q.top(); + q.pop(); + + while (!q.empty() && o.first != d[o.second]) { + o = q.top(); + q.pop(); + } + + if (!q.empty()) { + vis[o.second] = true; + d[o.second] = 0; + + ans = std::max(ans, o.first); + + for (int v : g[o.second]) { + if (!vis[v]) { + d[v]--; + q.emplace(d[v], v); + } + } + } + } + + cout << ans << endl; + + return 0; +} diff --git a/NFLSOJ/0/3692/samples/graph1.ans b/NFLSOJ/0/3692/samples/graph1.ans new file mode 100644 index 00000000..ca267b30 --- /dev/null +++ b/NFLSOJ/0/3692/samples/graph1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1121cfccd5913f0a63fec40a6ffd44ea64f9dc135c66634ba001d10bcf4302a2 +size 2 diff --git a/NFLSOJ/0/3692/samples/graph1.in b/NFLSOJ/0/3692/samples/graph1.in new file mode 100644 index 00000000..3e230069 --- /dev/null +++ b/NFLSOJ/0/3692/samples/graph1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d879433e7c8c62b417dd8719b68aee3bc333d20e28fa447b89458262763f5a20 +size 28 diff --git a/NFLSOJ/0/3692/samples/graph2.ans b/NFLSOJ/0/3692/samples/graph2.ans new file mode 100644 index 00000000..38118f32 --- /dev/null +++ b/NFLSOJ/0/3692/samples/graph2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53c234e5e8472b6ac51c1ae1cab3fe06fad053beb8ebfd8977b010655bfdd3c3 +size 2 diff --git a/NFLSOJ/0/3692/samples/graph2.in b/NFLSOJ/0/3692/samples/graph2.in new file mode 100644 index 00000000..1e62f6d3 --- /dev/null +++ b/NFLSOJ/0/3692/samples/graph2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04d21375c1acf6149e2d279a561cf9474c85af9fea7ac6ecf1c46ac30d3a2701 +size 28 diff --git a/NFLSOJ/0/3692/samples/graph3.ans b/NFLSOJ/0/3692/samples/graph3.ans new file mode 100644 index 00000000..9d49f52c --- /dev/null +++ b/NFLSOJ/0/3692/samples/graph3.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:69fa4dd4fdc0b43ba7ca7c997539c4500f03ab9b220228e2b1e97bd305397806 +size 3 diff --git a/NFLSOJ/0/3692/samples/graph3.in b/NFLSOJ/0/3692/samples/graph3.in new file mode 100644 index 00000000..d20ded25 --- /dev/null +++ b/NFLSOJ/0/3692/samples/graph3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48fd320b4cc8530f9292f3d44d0e4a0772aa853e068e840cd5887adf8e1d1196 +size 55751