Submission #569104

#TimeUsernameProblemLanguageResultExecution timeMemory
569104SSRSDuathlon (APIO18_duathlon)C++14
5 / 100
1098 ms5920 KiB
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> E(n);
  for (int i = 0; i < m; i++){
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    E[u].push_back(v);
    E[v].push_back(u);
  }
  int ans = 0;
  for (int s = 0; s < n; s++){
    for (int c = 0; c < n; c++){
      for (int f = 0; f < n; f++){
        if (s != c && s != f && c != f){
          bool ok = true;
          for (int u = 0; u < n; u++){
            if (u != c){
              vector<bool> used(n, false);
              used[c] = true;
              queue<int> Q;
              Q.push(c);
              while (!Q.empty()){
                int v = Q.front();
                Q.pop();
                for (int w : E[v]){
                  if (!used[w] && w != u){
                    used[w] = true;
                    Q.push(w);
                  }
                }
              }
              if (!used[s] && !used[f]){
                ok = false;
              }
            }
          }
          if (ok){
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...