Submission #444021

# Submission time Handle Problem Language Result Execution time Memory
444021 2021-07-13T02:21:10 Z yungyao The Collection Game (BOI21_swaps) C++17
5 / 100
50 ms 408 KB
using namespace std;
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <vector>
#include <memory.h>

typedef long long LL;
typedef pair<int,int> pii;
#define F first
#define S second
#define mkp make_pair
#define iter(x) x.begin(),x.end()
#define MEM(s,e) memset(s,e,sizeof(s))

const int maxn = 0;
#include <swaps.h>

bool ask(int u,int v){
    schedule(u,v);
    vector <int> ret = visit();
    return ret[0];
}

vector <int> mergesort(vector <int> v){
    if (v.size() == 1) return v;
    else if (v.size() == 2){
        if (ask(v[0],v[1])) return v;
        else return {v[1],v[0]};
    }

    vector <int> l,r;
    for (int i=0;i<v.size();++i){
        if (i < v.size() / 2) l.push_back(v[i]);
        else r.push_back(v[i]);
    }

    l = mergesort(l); r = mergesort(r);
    v.clear();
    for (int i=0,j=0;i<l.size() or j<r.size();){
        if (i<l.size() and j<r.size()){
            if (ask(l[i],r[j])) v.push_back(l[i++]);
            else v.push_back(r[j++]);
        }
        else if (i < l.size()) v.push_back(l[i++]);
        else v.push_back(r[j++]);
    }
    return v;
}

void solve(int n,int v){
    vector <int> arr(n);
    for (int i=0;i<n;++i) arr[i] = i + 1;
    arr = mergesort(arr);
    answer(arr);
}

Compilation message

swaps.cpp: In function 'std::vector<int> mergesort(std::vector<int>)':
swaps.cpp:37:19: 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=0;i<v.size();++i){
      |                  ~^~~~~~~~~
swaps.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         if (i < v.size() / 2) l.push_back(v[i]);
      |             ~~^~~~~~~~~~~~~~
swaps.cpp:44:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for (int i=0,j=0;i<l.size() or j<r.size();){
      |                      ~^~~~~~~~~
swaps.cpp:44:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for (int i=0,j=0;i<l.size() or j<r.size();){
      |                                    ~^~~~~~~~~
swaps.cpp:45:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         if (i<l.size() and j<r.size()){
      |             ~^~~~~~~~~
swaps.cpp:45:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         if (i<l.size() and j<r.size()){
      |                            ~^~~~~~~~~
swaps.cpp:49:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         else if (i < l.size()) v.push_back(l[i++]);
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 7 ms 200 KB Correct
3 Correct 13 ms 288 KB Correct
4 Correct 38 ms 200 KB Correct
5 Correct 27 ms 200 KB Correct
6 Correct 28 ms 200 KB Correct
7 Correct 50 ms 200 KB Correct
8 Correct 30 ms 200 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 7 ms 200 KB Correct
3 Correct 22 ms 200 KB Correct
4 Correct 50 ms 200 KB Correct
5 Correct 28 ms 200 KB Correct
6 Correct 20 ms 200 KB Correct
7 Correct 41 ms 200 KB Correct
8 Correct 49 ms 200 KB Correct
9 Runtime error 12 ms 408 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Not correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Not correct
2 Halted 0 ms 0 KB -