Submission #872186

#TimeUsernameProblemLanguageResultExecution timeMemory
872186MatjazParachute rings (IOI12_rings)C++14
20 / 100
4040 ms33320 KiB
#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 (stderr)

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 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...