제출 #143126

#제출 시각아이디문제언어결과실행 시간메모리
143126legendArranging Shoes (IOI19_shoes)C++17
0 / 100
1065 ms16020 KiB
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;

long long count_swaps(std::vector<int> s) {
	set<pair<int,int> > ms;
    map<int,int> pos;
	for(int i = 0;i<s.size();i++){
            if(s[i]<0) ms.insert({i,s[i]});
            pos[s[i]] = i;
	}
    int ps = 0;
    long long ans = 0;
    while(ps<s.size()){
        pair<int,int> x;
        for(int i = ps;;i++){
            if(s[i]<0){
                x = {i,s[i]};
                break;
            }
        }
        for(int i = ps;i<x.first;i++){
            int u = s[i];
            pos[u]++;
        }
        for(int i = x.first;i>ps;i--){
            swap(s[i],s[i-1]);
        }
        for(int i = ps+1;;i++){
            if(s[i] == -x.second){
                ans+=(i-ps-1);
                for(int j = i;j>ps+1;j--) swap(s[j],s[j-1]);
                break;
            }

        }
      //  cout<<ans<<endl;
        ps+=2;
    }
    return ans;
	return 1;
}

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:8:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0;i<s.size();i++){
                ~^~~~~~~~~
shoes.cpp:14:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(ps<s.size()){
           ~~^~~~~~~~~
#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...