제출 #339403

#제출 시각아이디문제언어결과실행 시간메모리
339403KerimArranging Shoes (IOI19_shoes)C++17
50 / 100
1094 ms15988 KiB
#include "bits/stdc++.h"
#include "shoes.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;
 
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
using namespace std;
int vis[MAXN];
vector<int>a[MAXN],b[MAXN];
long long count_swaps(std::vector<int> s) {
	int n=s.size(),ans=0;
	for(int i=n-1;i>=0;i--){
		if(s[i]>0)a[s[i]].pb(i);
		else b[-s[i]].pb(i);	
	}
	for(int i=0,j;i<n;i++){
		if(vis[i])continue;
		if(s[i]>0)j=b[s[i]].back();
		else j=a[-s[i]].back();vis[j]=1;
		a[abs(s[i])].ppb();b[abs(s[i])].ppb();
		ans+=(s[i]>s[j]);
		vis[j]=1;ans+=j-i-1;
		for(int k=i+1;k<j;k++)ans-=vis[k];
	}
	return ans;
}
/*
int main() {
	freopen("file.in","r",stdin);
	int n;
	assert(1 == scanf("%d", &n));
	vector<int> S(2 * n);
	for (int i = 0; i < 2 * n; i++)
		assert(1 == scanf("%d", &S[i]));
 
	long long result = count_swaps(S);
 
	printf("%lld\n", result);
	return 0;
}*/

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:33:3: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
   33 |   else j=a[-s[i]].back();vis[j]=1;
      |   ^~~~
shoes.cpp:33:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
   33 |   else j=a[-s[i]].back();vis[j]=1;
      |                          ^~~
#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...