Submission #872186

# Submission time Handle Problem Language Result Execution time Memory
872186 2023-11-12T13:09:39 Z Matjaz Parachute rings (IOI12_rings) C++14
20 / 100
4000 ms 33320 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;
            if (found[i]) 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:52:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |                 for (int i=0;i<s[x].size();i++){
      |                              ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 224 ms 736 KB Output is correct
3 Correct 360 ms 804 KB Output is correct
4 Correct 14 ms 504 KB Output is correct
5 Correct 138 ms 636 KB Output is correct
6 Correct 355 ms 804 KB Output is correct
7 Correct 148 ms 604 KB Output is correct
8 Correct 180 ms 720 KB Output is correct
9 Correct 347 ms 808 KB Output is correct
10 Correct 368 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4019 ms 33320 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 224 ms 736 KB Output is correct
3 Correct 360 ms 804 KB Output is correct
4 Correct 14 ms 504 KB Output is correct
5 Correct 138 ms 636 KB Output is correct
6 Correct 355 ms 804 KB Output is correct
7 Correct 148 ms 604 KB Output is correct
8 Correct 180 ms 720 KB Output is correct
9 Correct 347 ms 808 KB Output is correct
10 Correct 368 ms 604 KB Output is correct
11 Execution timed out 4040 ms 980 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 224 ms 736 KB Output is correct
3 Correct 360 ms 804 KB Output is correct
4 Correct 14 ms 504 KB Output is correct
5 Correct 138 ms 636 KB Output is correct
6 Correct 355 ms 804 KB Output is correct
7 Correct 148 ms 604 KB Output is correct
8 Correct 180 ms 720 KB Output is correct
9 Correct 347 ms 808 KB Output is correct
10 Correct 368 ms 604 KB Output is correct
11 Execution timed out 4040 ms 980 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 224 ms 736 KB Output is correct
3 Correct 360 ms 804 KB Output is correct
4 Correct 14 ms 504 KB Output is correct
5 Correct 138 ms 636 KB Output is correct
6 Correct 355 ms 804 KB Output is correct
7 Correct 148 ms 604 KB Output is correct
8 Correct 180 ms 720 KB Output is correct
9 Correct 347 ms 808 KB Output is correct
10 Correct 368 ms 604 KB Output is correct
11 Execution timed out 4019 ms 33320 KB Time limit exceeded
12 Halted 0 ms 0 KB -