Submission #778597

# Submission time Handle Problem Language Result Execution time Memory
778597 2023-07-10T12:59:19 Z Sandarach151 Carnival (CEOI14_carnival) C++17
20 / 100
64 ms 416 KB
#include<bits/stdc++.h>
using namespace std;

vector<vector<int>> func(vector<int> vect){
    if(vect.size()==1){
        vector<vector<int>> ans;
        vector<int> temp;
        temp.push_back(vect[0]);
        ans.push_back(temp);
        return ans;
    }
    else{
        cout << vect.size();
        for(int i=0; i<vect.size(); i++){
            cout << ' ' << vect[i];
        }
        cout << endl;
        int a;
        cin >> a;
        if(a==vect.size()){
            vector<vector<int>> ans;
            for(int i=0; i<vect.size(); i++){
                int b = vect[i];
                vector<int> temp4;
                temp4.push_back(b);
                ans.push_back(temp4);
            }
            return ans;
        }
        else{
            int mid = vect.size()/2;
            vector<int> vect1;
            vector<int> vect2;
            for(int i=0; i<mid; i++){
                vect1.push_back(vect[i]);
            }
            for(int i=mid; i<vect.size(); i++){
                vect2.push_back(vect[i]);
            }
            vector<vector<int>> temp1 = func(vect1);
            vector<vector<int>> temp2 = func(vect2);
            for(int i=0; i<temp1.size(); i++){
                for(int j=0; j<temp2.size(); j++){
                    if(temp2[j][0]!=-1){
                        cout << 2 << ' ' << temp1[i][0] << ' ' << temp2[j][0] << endl;
                        int a;
                        cin >> a;
                        if(a==1){
                            for(int k=0; k<temp2[j].size(); k++){
                                temp1[i].push_back(temp2[j][k]);
                            }
                            temp2[j][0]=-1;
                        }
                    }
                }
            }
            for(int i=0; i<temp2.size(); i++){
                if(temp2[i][0]!=-1){
                    temp1.push_back(temp2[i]);
                }
            }
            return temp1;
        }
    }
}

int main(){
    int n;
    cin >> n;
    vector<vector<int>> ans;
    vector<int> people;
    for(int i=1; i<=n; i++){
        people.push_back(i);
    }
    ans = func(people);
    vector<int> finans(n+1);
    for(int i=0; i<ans.size(); i++){
        for(int j=0; j<ans[i].size(); j++){
            finans[ans[i][j]]=i+1;
        }
    }
    cout << 0;
    for(int i=1; i<=n; i++){
        cout << ' ' << finans[i];
    }
    return 0;
}

Compilation message

carnival.cpp: In function 'std::vector<std::vector<int> > func(std::vector<int>)':
carnival.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         for(int i=0; i<vect.size(); i++){
      |                      ~^~~~~~~~~~~~
carnival.cpp:20:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         if(a==vect.size()){
      |            ~^~~~~~~~~~~~~
carnival.cpp:22:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             for(int i=0; i<vect.size(); i++){
      |                          ~^~~~~~~~~~~~
carnival.cpp:37:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |             for(int i=mid; i<vect.size(); i++){
      |                            ~^~~~~~~~~~~~
carnival.cpp:42:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             for(int i=0; i<temp1.size(); i++){
      |                          ~^~~~~~~~~~~~~
carnival.cpp:43:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |                 for(int j=0; j<temp2.size(); j++){
      |                              ~^~~~~~~~~~~~~
carnival.cpp:49:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |                             for(int k=0; k<temp2[j].size(); k++){
      |                                          ~^~~~~~~~~~~~~~~~
carnival.cpp:57:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |             for(int i=0; i<temp2.size(); i++){
      |                          ~^~~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:77:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |     for(int i=0; i<ans.size(); i++){
      |                  ~^~~~~~~~~~~
carnival.cpp:78:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |         for(int j=0; j<ans[i].size(); j++){
      |                      ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 208 KB Output is correct
2 Correct 17 ms 208 KB Output is correct
3 Partially correct 20 ms 312 KB Partially correct
4 Partially correct 53 ms 300 KB Partially correct
5 Correct 2 ms 304 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 18 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 16 ms 208 KB Output is correct
3 Partially correct 31 ms 288 KB Partially correct
4 Partially correct 26 ms 336 KB Partially correct
5 Correct 5 ms 208 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Partially correct 38 ms 292 KB Partially correct
4 Partially correct 53 ms 296 KB Partially correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 10 ms 304 KB Output is correct
7 Correct 27 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Partially correct 64 ms 208 KB Partially correct
4 Partially correct 46 ms 304 KB Partially correct
5 Correct 9 ms 312 KB Output is correct
6 Correct 26 ms 208 KB Output is correct
7 Correct 17 ms 416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 13 ms 208 KB Output is correct
3 Partially correct 53 ms 312 KB Partially correct
4 Partially correct 42 ms 296 KB Partially correct
5 Partially correct 22 ms 208 KB Partially correct
6 Partially correct 49 ms 308 KB Partially correct
7 Partially correct 45 ms 308 KB Partially correct