Submission #579473

# Submission time Handle Problem Language Result Execution time Memory
579473 2022-06-19T08:29:25 Z web Carnival (CEOI14_carnival) C++17
0 / 100
124 ms 452 KB
#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

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 time Memory Grader output
1 Correct 16 ms 208 KB Output is correct
2 Correct 25 ms 208 KB Output is correct
3 Partially correct 102 ms 324 KB Partially correct
4 Runtime error 124 ms 324 KB Execution killed with signal 13
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 33 ms 324 KB Output is correct
3 Partially correct 52 ms 208 KB Partially correct
4 Runtime error 118 ms 328 KB Execution killed with signal 13
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 4 ms 324 KB Output is correct
3 Partially correct 50 ms 320 KB Partially correct
4 Runtime error 56 ms 340 KB Execution killed with signal 13
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Runtime error 96 ms 444 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 21 ms 208 KB Output is correct
3 Partially correct 83 ms 328 KB Partially correct
4 Partially correct 81 ms 452 KB Partially correct
5 Partially correct 49 ms 336 KB Partially correct
6 Partially correct 97 ms 324 KB Partially correct
7 Runtime error 51 ms 336 KB Execution killed with signal 13
8 Halted 0 ms 0 KB -