Submission #579473

#TimeUsernameProblemLanguageResultExecution timeMemory
579473webCarnival (CEOI14_carnival)C++17
0 / 100
124 ms452 KiB
#include <iostream> #include <vector> #include <string> #include <set> #include <math.h> using namespace std; vector<vector<int>> merge(vector<vector<int>> v1, vector<vector<int>> v2) { if(v1.size() == 0) return v2; if(v2.size() == 0) return v1; if(v1.size() < v2.size()) swap(v1,v2); for(int j = 0; j<v2.size(); ++j) { bool found = false; for(int i = 0; i<v1.size(); ++i) { cout<<2<<" "<<v1[i][0]+1<<" "<<v2[j][0]+1<<endl; int res; cin>>res; if(res == 1) { found = true; for(int k = 0; k<v2[j].size(); ++k) { v1[i].push_back(v2[j][k]); } break; } } if(!found) { v1.push_back(v2[j]); } } return v1; } vector<vector<int>> mergeSort(vector<vector<int>> friends) { if(friends.size() == 1) return friends; if(friends.size() == 0) return vector<vector<int>>(0); int mid = friends.size()/2; vector<vector<int>> sort1 = mergeSort(vector<vector<int>>(friends.begin(), friends.begin() + mid)); vector<vector<int>> sort2 = mergeSort(vector<vector<int>>(friends.begin() + mid, friends.end())); return merge(sort1, sort2); } int main() { int numFriendsKnown = 0; int numFriendsTotal; cin>>numFriendsTotal; vector<vector<int>> fr(numFriendsTotal); for(int i = 0; i<numFriendsTotal; ++i) { fr[i] = {i}; } vector<vector<int>> groups = mergeSort(fr); for(int i = 0; i<groups.size(); ++i) { for(int j =0; j<groups[i].size(); ++j) { fr[groups[i][j]] = {i+1}; } } cout<<0<<" "; for(int i = 0; i<fr.size(); ++i) { cout<<fr[i][0]<<" "; } cout<<endl; return 0; }

Compilation message (stderr)

carnival.cpp: In function 'std::vector<std::vector<int> > merge(std::vector<std::vector<int> >, std::vector<std::vector<int> >)':
carnival.cpp:17:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int j = 0; j<v2.size(); ++j)
      |                    ~^~~~~~~~~~
carnival.cpp:21:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for(int i = 0; i<v1.size(); ++i)
      |                        ~^~~~~~~~~~
carnival.cpp:28:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |                 for(int k = 0; k<v2[j].size(); ++k)
      |                                ~^~~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:70:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     for(int i = 0; i<groups.size(); ++i)
      |                    ~^~~~~~~~~~~~~~
carnival.cpp:72:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |         for(int j =0; j<groups[i].size(); ++j)
      |                       ~^~~~~~~~~~~~~~~~~
carnival.cpp:78:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |     for(int i = 0; i<fr.size(); ++i)
      |                    ~^~~~~~~~~~
carnival.cpp:61:9: warning: unused variable 'numFriendsKnown' [-Wunused-variable]
   61 |     int numFriendsKnown = 0;
      |         ^~~~~~~~~~~~~~~
#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...