Submission #872184

# Submission time Handle Problem Language Result Execution time Memory
872184 2023-11-12T13:05:41 Z Matjaz Parachute rings (IOI12_rings) C++14
0 / 100
4000 ms 33092 KB

#include <vector>
#include <queue>

using namespace std;


int N;
vector<vector<int> > s;

void Init(int N_) {
    N = N_;
    s.assign(N, vector <int> ());
}

void Link(int A, int B) {
    s[A].push_back(B);
    s[B].push_back(A);

}

int CountCritical() {
    int res = 0;
    
    for (int t=0;t<N;t++){
        vector<int> d(N);
        for (int i=0;i<N;i++) d[i] = s[i].size();
        for (int i=0;i<s[t].size();i++) d[s[t][i]]--;
        
        vector<int> found(N, 0);
        bool critical = true;
        for (int i=0;i<N;i++){
            if (i == t) continue;
            found[i] = true;
            
            if (d[i] == 0) continue;
            
            int countOne = 0;
            
            queue<int> Q;
            Q.push(i);
            
            while (!Q.empty()){
                int x = Q.front();Q.pop();
                if (d[x] > 2){
                    critical = false;
                    break;
                }
                if (d[x] == 1) countOne++;
                for (int i=0;i<s[x].size();i++){
                    if (s[x][i] == t) continue;
                    if (found[s[x][i]]) continue;
                    found[s[x][i]] = true;
                    Q.push(s[x][i]);
                    
                }
            }
            if (countOne != 2) critical = false;
        }
        
        if (critical) res++;
    }
    
    return res;
}

Compilation message

rings.cpp: In function 'int CountCritical()':
rings.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for (int i=0;i<s[t].size();i++) d[s[t][i]]--;
      |                      ~^~~~~~~~~~~~
rings.cpp:51:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |                 for (int i=0;i<s[x].size();i++){
      |                              ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4070 ms 33092 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -