Submission #1109861

# Submission time Handle Problem Language Result Execution time Memory
1109861 2024-11-07T23:23:22 Z ozner77 Parachute rings (IOI12_rings) C++17
0 / 100
111 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;
map<long long,long long> sumas;
    vector<vector<long long>> V;
    vector<int> p, r;
    void UnionFind(int n) {
        p.resize(n);
        r.resize(n, 0);
        for (int i = 0; i < n; ++i) {
            p[i] = i;
        }
    }
    int encontrar(int x) {
        if (p[x] != x) {
            p[x] = encontrar(p[x]);
        }
        return p[x];
    }
    void unir(int x, int y) {
        int rx = encontrar(x);
        int ry = encontrar(y);
        if (rx != ry) {
            if (r[rx] > r[ry]) {
                p[ry] = rx;
            } else if (r[rx] < r[ry]) {
                p[rx] = ry;
            } else {
                p[ry] = rx;
                r[rx]++;
            }
        }
    }
    bool conectados(int x, int y) {
        return encontrar(x) == encontrar(y);
    }
int N;
void Init(int N){
    vector<long long> V1(N,0);
    for(int i=0;i<N;i++){
        V.push_back(V1);
    }
    UnionFind(N);
}
void Link(int A,int B){
    unir(A,B);
    V[A][B]=1;
    V[B][A]=1;
    sumas[A]++;
    sumas[B]++;
}
int CountCritical(){
    int res=0;
    bool vale;
    vector<long long> Puntas;
    for(int i=0;i<N;i++){
        bool vale=true;
        Puntas.clear();
        for(int j=0;j<N;j++){
            if(j!=i){
                if(V[i][j]==1){
                    sumas[j]--;
                }
                if(sumas[j]>=3){
                    vale=false;
                    break;
                }else if(sumas[j]==1){
                    Puntas.push_back(j);
                }
                if(V[i][j]==1){
                    sumas[j]++;
                }
            }
        }
        map<long long,long long> C;
        C.clear();
        for(auto x:Puntas){
            C[encontrar(x)]++;
            if(C[encontrar(x)]>2){
                 vale=false;
                break;
            }
        }
        if(vale){
            res++;
        }
    }
    return res;
}

Compilation message

rings.cpp: In function 'int CountCritical()':
rings.cpp:53:10: warning: unused variable 'vale' [-Wunused-variable]
   53 |     bool vale;
      |          ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 111 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -