Submission #432117

# Submission time Handle Problem Language Result Execution time Memory
432117 2021-06-17T21:15:00 Z SuhaibSawalha1 Duathlon (APIO18_duathlon) C++17
0 / 100
1000 ms 11648 KB
#include <bits/stdc++.h>
using namespace std;

int n, m, vid, vid2;
vector<vector<int>> adj;
vector<int> vis, stck, st;
long long ans;

void dfs (int u, int k) {
  vis[u] = vid;
  if (u == k) {
    for (int v : stck) {
      st[v] = vid2;
    }
  }
  stck.push_back(u);
  for (int v : adj[u]) {
    if (vis[v] != vid) {
      dfs(v, k);
    }
  }
  stck.pop_back();
  vis[u] = 0;
}
    
int main (){

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

  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);
  }    
  vis.resize(n);
  st.resize(n);
  for (int u = 0; u < n; ++u) {
    for (int v = 0; v < n; ++v) {
      if (u ^ v) {
        ++vid;
        ++vid2;
        dfs(u, v);
        ans += max(0, (int)count(st.begin(), st.end(), vid2) - 1);
      }
    }
  }
  cout << ans;

  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 100 ms 288 KB Output is correct
10 Execution timed out 1077 ms 204 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 100 ms 288 KB Output is correct
10 Execution timed out 1077 ms 204 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 11648 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 6592 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 6596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 100 ms 288 KB Output is correct
10 Execution timed out 1077 ms 204 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 100 ms 288 KB Output is correct
10 Execution timed out 1077 ms 204 KB Time limit exceeded
11 Halted 0 ms 0 KB -