Submission #89001

#TimeUsernameProblemLanguageResultExecution timeMemory
89001gbutbaiaTriumphal arch (POI13_luk)C++14
0 / 100
3 ms916 KiB
#include <iostream> #include <vector> #include <set> #include <string> using namespace std; vector<vector<int>> tree(100); int res(set<int> checked, int a) { int count = 0; for(int i = 0; i<tree[a].size(); i++) { if(checked.count(tree[a][i]) == 0) {count++;} } return count; } //Filters out only nonChecked ones vector<int> getNonCheckedNeighborhood(set<int> checked, vector<int> depthLevel) { vector<int> result; for(int elem : depthLevel) { if(checked.count(elem) == 0) {result.push_back(elem);} } return result; } //for point= tree[i][j] do the following: //For each element in nonCheckedNeighborhood //count the size of nonCheckedNeightborhood, then go down void printVector(vector<int> a) { cout << "vec: {"; for(int elem : a) { cout << elem << ", "; } cout << "}" << endl; } int prevResult = 0; void findNumber(int point, set<int> &checked) { vector<int> N = getNonCheckedNeighborhood(checked, tree[point]); //NonChecked neighborhood // cout << "Size: " << N.size() << endl; if(N.size() >prevResult) prevResult = N.size(); // printVector(N); checked.insert(point); for(int i = 0; i < N.size(); i++) { findNumber(N[i], checked); } } int main(){ int n; cin >> n; for(int i =0; i < n-1; i++) { int a,b = 0; cin >> a; cin >> b; //cout << a-1 << " " << b-1 << endl; tree[a-1].push_back(b-1); tree[b-1].push_back(a-1); } //Here tree is the folloiwg //tree[0] = {1,2,3}; tree[1] = {0}, tree[2] = {0,3,4,5}, tree[3] = {0} set<int> checked = {}; findNumber(0, checked); cout << prevResult<< endl; return 0; }

Compilation message (stderr)

luk.cpp: In function 'int res(std::set<int>, int)':
luk.cpp:14:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i<tree[a].size(); i++) {
                    ~^~~~~~~~~~~~~~~
luk.cpp: In function 'void findNumber(int, std::set<int>&)':
luk.cpp:48:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(N.size() >prevResult) prevResult = N.size();
        ~~~~~~~~~^~~~~~~~~~~
luk.cpp:51:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < N.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...
#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...