Submission #1009017

# Submission time Handle Problem Language Result Execution time Memory
1009017 2024-06-27T07:58:57 Z Rifal Parachute rings (IOI12_rings) C++14
0 / 100
4000 ms 47208 KB
#include <bits/stdc++.h>
//#include "rings.h"
using namespace std;
const int N = 1e6 + 5;
int n;
int cnt = 0;
vector<int> v[N];
int deg[N], nod;
int sum = 0;
bool vis[N], cy;
void dfs(int s, int p) {
  vis[s] = 1;
  for(auto i : v[s]) {
    if(i != p && i != nod) {
      if(vis[i] == 1) {
        cy = false;
      }
      else {
        dfs(i,s);
      }
    }
  }
}
void Init(int N_) {
  n = N_;
}

void Link(int A, int B) {
  deg[A]++; deg[B]++;
  if(deg[A] > 2) cnt++;
  if(deg[B] > 2) cnt++;
  v[A].push_back(B);
  v[B].push_back(A);
}

int CountCritical() {
  int sol = 0;
  sum++;
  for(int i = 0; i < n; i++) {
    int cur = cnt;
    if(deg[i] > 2) cur--;
    for(auto j : v[i]) {
      if(deg[j] == 3) cur--;
    }
    if(cur == 0) {
      cy = true;
      for(int j = 0; j < n; j++) vis[j] = 0;
      nod = i;
      for(int j = 0; j < n; j++) {
        if(vis[j] == 0 && j != nod) {
          dfs(j,-1);
        }
      }
      if(cy == true) {
         sol++;
      }
    }
  }
  return sol;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 26460 KB Output is correct
2 Incorrect 6 ms 26716 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4024 ms 47208 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 26460 KB Output is correct
2 Incorrect 6 ms 26716 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 26460 KB Output is correct
2 Incorrect 6 ms 26716 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 26460 KB Output is correct
2 Incorrect 6 ms 26716 KB Output isn't correct
3 Halted 0 ms 0 KB -