Submission #778632

# Submission time Handle Problem Language Result Execution time Memory
778632 2023-07-10T13:50:39 Z Sandarach151 Carnival (CEOI14_carnival) C++17
0 / 100
15 ms 316 KB
#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]);
            }
            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++;
        }
    }
    cout << 0;
    for(int i=0; i<n; i++){
		cout << ' ' << ans[i];
	}
    return 0;
}

Compilation message

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:74:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |             for(int i=0; i<temp2.size(); i++){
      |                          ~^~~~~~~~~~~~~
carnival.cpp:76:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |                 for(int j=0; j<vect.size(); j++){
      |                              ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 208 KB Output is correct
2 Correct 10 ms 308 KB Output is correct
3 Incorrect 8 ms 308 KB Incorrect
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 304 KB Output is correct
2 Correct 11 ms 208 KB Output is correct
3 Incorrect 7 ms 208 KB Incorrect
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 15 ms 316 KB Output is correct
4 Incorrect 7 ms 208 KB Incorrect
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 10 ms 308 KB Output is correct
4 Incorrect 7 ms 308 KB Incorrect
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 14 ms 308 KB Output is correct
3 Incorrect 9 ms 208 KB Incorrect
4 Halted 0 ms 0 KB -