Submission #603306

#TimeUsernameProblemLanguageResultExecution timeMemory
603306DanerZeinArt Collections (BOI22_art)C++17
50 / 100
863 ms32136 KiB
#include "art.h" #include <bits/stdc++.h> using namespace std; map<vector<int>,int> que; int cost(vector<int> x,int i,int j){ swap(x[i],x[j]); if(que.find(x)!=que.end()) return que[x]; return que[x]=publish(x); } void printA(vector<int> &y){ for(int i=0;i<y.size();i++) cout<<y[i]<<" "; cout<<endl; } int ori; vector<int> ord; vector<int> merge_sort(vector<int> x){ if(x.size()==1) return x; vector<int> m1,m2; for(int i=0;i<x.size()/2;i++) m1.push_back(x[i]); for(int i=x.size()/2;i<x.size();i++) m2.push_back(x[i]); m1=merge_sort(m1); m2=merge_sort(m2); vector<int> o; int i=0,j=0; while(i!=m1.size() || j!=m2.size()){ if(i==m1.size()){ o.push_back(m2[j]); j++; continue; } if(j==m2.size()){ o.push_back(m1[i]); i++; continue; } if(cost(ord,m1[i]-1,m2[j]-1)>ori){ o.push_back(m1[i]); i++; } else { o.push_back(m2[j]); j++; } } return o; } void solve(int N) { for(int i=1;i<=N;i++) ord.push_back(i); ori=publish(ord); ord=merge_sort(ord); answer(ord); }

Compilation message (stderr)

art.cpp: In function 'void printA(std::vector<int>&)':
art.cpp:12:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   for(int i=0;i<y.size();i++) cout<<y[i]<<" ";
      |               ~^~~~~~~~~
art.cpp: In function 'std::vector<int> merge_sort(std::vector<int>)':
art.cpp:20:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int i=0;i<x.size()/2;i++) m1.push_back(x[i]);
      |               ~^~~~~~~~~~~
art.cpp:21:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   for(int i=x.size()/2;i<x.size();i++) m2.push_back(x[i]);
      |                        ~^~~~~~~~~
art.cpp:26:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   while(i!=m1.size() || j!=m2.size()){
      |         ~^~~~~~~~~~~
art.cpp:26:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   while(i!=m1.size() || j!=m2.size()){
      |                         ~^~~~~~~~~~~
art.cpp:27:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     if(i==m1.size()){
      |        ~^~~~~~~~~~~
art.cpp:31:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     if(j==m2.size()){
      |        ~^~~~~~~~~~~
interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
#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...