Submission #362163

#TimeUsernameProblemLanguageResultExecution timeMemory
362163ogibogi2004Cheerleaders (info1cup20_cheerleaders)C++14
26 / 100
2079 ms2696 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long vector<int>moves; int ans=213013213,n; vector<int>output; void rec(vector<ll>h,ll d) { int s=0; for(int i=0;i<h.size();++i) { for(int j=i+1;j<h.size();++j) { if(h[j]<h[i])++s; } } /*for(int j=0;j<moves.size();j++)cout<<moves[j]; cout<<endl; for(int j=0;j<h.size();j++) { cout<<h[j]<<" "; } cout<<endl; cout<<s<<endl;*/ if(s<ans) { ans=s; output=moves; } if(d==3*n)return; vector<ll>h1; if(moves.size()==0||moves.back()==2) { for(int j=h.size()/2;j<h.size();++j)h1.push_back(h[j]); for(int j=0;j<h.size()/2;++j)h1.push_back(h[j]); moves.push_back(1); rec(h1,d+1); moves.pop_back(); h1.clear(); } for(int j=0;j<h.size();++j) { if(j%2==0)h1.push_back(h[j]); } for(int j=0;j<h.size();++j) { if(j%2==1)h1.push_back(h[j]); } moves.push_back(2); rec(h1,d+1); moves.pop_back(); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n; vector<ll>v; for(int i=1;i<=(1<<n);++i) { int x; cin>>x; v.push_back(x); } rec(v,0); cout<<ans<<'\n'; for(auto xd:output)cout<<xd; cout<<'\n'; return 0; }

Compilation message (stderr)

cheerleaders.cpp: In function 'void rec(std::vector<long long int>, long long int)':
cheerleaders.cpp:10:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  for(int i=0;i<h.size();++i)
      |              ~^~~~~~~~~
cheerleaders.cpp:12:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   for(int j=i+1;j<h.size();++j)
      |                 ~^~~~~~~~~
cheerleaders.cpp:34:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   for(int j=h.size()/2;j<h.size();++j)h1.push_back(h[j]);
      |                        ~^~~~~~~~~
cheerleaders.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for(int j=0;j<h.size()/2;++j)h1.push_back(h[j]);
      |               ~^~~~~~~~~~~
cheerleaders.cpp:41:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int j=0;j<h.size();++j)
      |              ~^~~~~~~~~
cheerleaders.cpp:45:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |  for(int j=0;j<h.size();++j)
      |              ~^~~~~~~~~
#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...