Submission #432119

# Submission time Handle Problem Language Result Execution time Memory
432119 2021-06-17T21:19:12 Z SuhaibSawalha1 Duathlon (APIO18_duathlon) C++17
0 / 100
3 ms 332 KB
#include <bits/stdc++.h>
using namespace std;

int n, m;
vector<vector<int>> adj;
bitset<50> st, stck;
long long ans;

void dfs (int u, int k) {
  if (u == k) {
    st |= stck;
  }
  stck[u] = 1;
  for (int v : adj[u]) {
    if (!stck[v]) {
      dfs(v, k);
    }
  }
  stck[u] = 0;
}
    
int main (){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  freopen("SuhaibSawalha1","r",stdin);

  cin >> n >> m;
  adj.resize(n);
  while (m--) {
    int u, v;
    cin >> u >> v, --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }    
  for (int u = 0; u < n; ++u) {
    for (int v = 0; v < n; ++v) {
      if (u ^ v) {
        dfs(u, v);
        ans += max(0, (int)st.count() - 1);
        st.reset();
      }
    }
  }
  cout << ans;

  return 0;
}

Compilation message

count_triplets.cpp: In function 'int main()':
count_triplets.cpp:27:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   freopen("SuhaibSawalha1","r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -