Submission #821056

#TimeUsernameProblemLanguageResultExecution timeMemory
821056boris_mihovMarshmallow Molecules (CCO19_day2problem2)C++17
5 / 25
4075 ms72656 KiB
#include <algorithm> #include <iostream> #include <numeric> #include <cassert> #include <vector> #include <queue> #include <stack> #include <set> #include <map> typedef long long llong; const int MAXN = 5000 + 10; const llong INF = 1e18; const int INTINF = 1e9; int n, m; bool c[MAXN][MAXN]; std::vector <int> g[MAXN]; void solve() { for (int i = 1 ; i <= n ; ++i) { for (const int &u : g[i]) { for (const int &v : g[i]) { if (u < v && !c[u][v]) { g[u].push_back(v); c[u][v] = true; } } } } int cnt = 0; for (int i = 1 ; i <= n ; ++i) { cnt += g[i].size(); } std::cout << cnt << '\n'; } void input() { std::cin >> n >> m; for (int i = 1 ; i <= m ; ++i) { int u, v; std::cin >> u >> v; g[std::min(u, v)].push_back(std::max(u, v)); c[u][v] = true; } } void fastIOI() { std::ios_base :: sync_with_stdio(0); std::cout.tie(nullptr); std::cin.tie(nullptr); } int main() { fastIOI(); input(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...