제출 #362159

#제출 시각아이디문제언어결과실행 시간메모리
362159ogibogi2004Cheerleaders (info1cup20_cheerleaders)C++14
0 / 100
2068 ms3424 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==2*n)return;
	vector<ll>h1;
	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(h[j]%2==0)h1.push_back(h[j]);
	}
	for(int j=0;j<h.size();j++)
	{
		if(h[j]%2==1)h1.push_back(h[j]);
	}
	moves.push_back(2);
	rec(h1,d+1);
	moves.pop_back();
}
int main()
{
	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<<endl;
	for(auto xd:output)cout<<xd;
	cout<<endl;
return 0;
}

컴파일 시 표준 에러 (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:32:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for(int j=h.size()/2;j<h.size();j++)h1.push_back(h[j]);
      |                       ~^~~~~~~~~
cheerleaders.cpp:33:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for(int j=0;j<h.size()/2;j++)h1.push_back(h[j]);
      |              ~^~~~~~~~~~~
cheerleaders.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for(int j=0;j<h.size();j++)
      |              ~^~~~~~~~~
cheerleaders.cpp:42:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for(int j=0;j<h.size();j++)
      |              ~^~~~~~~~~
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…