Submission #778644

#TimeUsernameProblemLanguageResultExecution timeMemory
778644Sandarach151Carnival (CEOI14_carnival)C++17
100 / 100
16 ms312 KiB
#include<bits/stdc++.h> using namespace std; int getNum(vector<int> vect){ if(vect.size()==1){ return 1; } cout << vect.size(); for(int i=0; i<vect.size(); i++){ cout << ' ' << vect[i]; } cout << endl; int a; cin >> a; return a; } vector<int> func(int cur, vector<int> vect){ // vect exculdes cur if(vect.size()==1){ return vect; } else{ int mid = vect.size()/2; vector<int> temp1, temp2, ans1, ans2; for(int i=0; i<mid; i++){ temp1.push_back(vect[i]); } for(int i=mid; i<vect.size(); i++){ temp2.push_back(vect[i]); } int a = getNum(temp1); temp1.push_back(cur); int b = getNum(temp1); if(b==a){ temp1.pop_back(); ans1 = func(cur, temp1); } int c = getNum(temp2); temp2.push_back(cur); int d = getNum(temp2); if(c==d){ temp2.pop_back(); ans2 = func(cur, temp2); } for(int i=0; i<ans2.size(); i++){ ans1.push_back(ans2[i]); } return ans1; } } int main(){ int n; cin >> n; vector<int> vect(n); for(int i=1; i<=n; i++){ vect[i-1]=i; } vector<int> ans(n); int pos = 1; while(vect.size()>0){ if(vect.size()==1){ ans[vect[0]-1]=pos; break; } else{ ans[vect[0]-1]=pos; int cur = vect[0]; vector<int> temp; for(int i=1; i<vect.size(); i++){ temp.push_back(vect[i]); } int a = getNum(temp); temp.push_back(vect[0]); int b = getNum(temp); temp.pop_back(); if(a==b){ vector<int> temp2 = func(cur, temp); for(int i=0; i<temp2.size(); i++){ ans[temp2[i]-1]=pos; for(int j=0; j<vect.size(); j++){ if(vect[j]==temp2[i]){ vect.erase(vect.begin()+j); break; } } } vect.erase(vect.begin()); pos++; } else{ vect.erase(vect.begin()); pos++; } } } cout << 0; for(int i=0; i<n; i++){ cout << ' ' << ans[i]; } return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int getNum(std::vector<int>)':
carnival.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=0; i<vect.size(); i++){
      |                  ~^~~~~~~~~~~~
carnival.cpp: In function 'std::vector<int> func(int, std::vector<int>)':
carnival.cpp:28:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int i=mid; i<vect.size(); i++){
      |                        ~^~~~~~~~~~~~
carnival.cpp:45:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for(int i=0; i<ans2.size(); i++){
      |                      ~^~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:70:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |             for(int i=1; i<vect.size(); i++){
      |                          ~^~~~~~~~~~~~
carnival.cpp:79:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |                 for(int i=0; i<temp2.size(); i++){
      |                              ~^~~~~~~~~~~~~
carnival.cpp:81:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |                     for(int j=0; j<vect.size(); j++){
      |                                  ~^~~~~~~~~~~~
#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...