Submission #432120

# Submission time Handle Problem Language Result Execution time Memory
432120 2021-06-17T21:19:24 Z SuhaibSawalha1 Duathlon (APIO18_duathlon) C++17
0 / 100
1000 ms 5828 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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 70 ms 204 KB Output is correct
10 Execution timed out 1088 ms 204 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 70 ms 204 KB Output is correct
10 Execution timed out 1088 ms 204 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 5740 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 5828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 5788 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 70 ms 204 KB Output is correct
10 Execution timed out 1088 ms 204 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 70 ms 204 KB Output is correct
10 Execution timed out 1088 ms 204 KB Time limit exceeded
11 Halted 0 ms 0 KB -