제출 #758396

#제출 시각아이디문제언어결과실행 시간메모리
758396TrumlingArranging Shoes (IOI19_shoes)C++14
30 / 100
1086 ms3780 KiB
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std; 

typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
#define INF 99999999999999999
#define MOD 1000000007
#define all(x) x.begin(),x.end()

long long count_swaps(std::vector<int> s) 
{
	ll nn=s.size();

	vector<int>v(nn/2);
	for(int i=0;i<nn;i+=2)
	v[i/2]=i;

	ll ans=INF;
	do
	{
	ll idx=0;
	vector<int>g(nn,-1);

	for(int i=0;i<nn;i++)
			if(s[i]<0)
				g[i]=v[idx++];
	
	ll curr=0;

	vector<int>now(nn);
	
	for(int i=0;i<nn;i++)
		now[i]=i;
	
	idx=0;
for(int r=0;r<nn;r++)
	for(int i=idx;i<nn;i++)
	{
		if(g[i]==idx)
		{
		for(int j=i-1;j>=idx;j--)
		{
			swap(now[j],now[j+1]);
			swap(g[j],g[j+1]);
			curr++;
		}

		for(int j=idx+1;j<nn;j++)
		if(s[now[j]]+s[now[idx]]==0)
		{
			for(int c=j-1;c>=idx+1;c--)
			{
			swap(now[c],now[c+1]);
			swap(g[c],g[c+1]);
			curr++;
			}
			break;
		}

		idx+=2;
		break;
		}
	}	
		
	ans=min(ans,curr);
	}while(next_permutation(all(v)));	
	

	return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:40:1: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   40 | for(int r=0;r<nn;r++)
      | ^~~
shoes.cpp:69:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   69 |  ans=min(ans,curr);
      |  ^~~
#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...