Submission #1162370

#TimeUsernameProblemLanguageResultExecution timeMemory
1162370blackslex조이터에서 친구를 만드는건 재밌어 (JOI20_joitter2)C++20
0 / 100
0 ms528 KiB
#include<bits/stdc++.h> using namespace std; int n, m, x, y; int main() { scanf("%d %d", &n, &m); vector<vector<bool>> f(n + 5, vector<bool>(n + 5)); vector<vector<int>> v(n + 5, vector<int>()); int ans = 0; auto add = [&] (auto &&add, int x, int y) -> void { if (f[x][y]) return; f[x][y] = 1; ans++; for (auto &e: v[y]) { if (x != e && !f[x][e]) add(add, x, e); } if (f[y][x]) { for (int i = 1; i <= n; i++) { if (i != x && i != y) { if (f[i][x] && !f[i][y]) add(add, i, y); if (f[i][y] && !f[i][x]) add(add, i, x); } } v[x].emplace_back(y); v[y].emplace_back(x); } }; while (m--) { scanf("%d %d", &x, &y); if (!f[x][y]) add(add, x, y); printf("%d\n", ans); } }

Compilation message (stderr)

joitter2.cpp: In function 'int main()':
joitter2.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
joitter2.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         scanf("%d %d", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...