Submission #444021

#TimeUsernameProblemLanguageResultExecution timeMemory
444021yungyaoThe Collection Game (BOI21_swaps)C++17
5 / 100
50 ms408 KiB
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 (stderr)

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 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...
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...