제출 #253510

#제출 시각아이디문제언어결과실행 시간메모리
253510BadrangiikhArranging Shoes (IOI19_shoes)C++14
10 / 100
1098 ms2296 KiB
#include<bits/stdc++.h>
#include <deque> 
#include <cmath>
using namespace std;
 
#define ll long long 
 
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
 
long long count_swaps ( vector < int > s ) {
    int n = s . size ( ) ;
    long long x = 0 ;
    int y = 0 ;
    while ( s . size ( ) > 0 ) {
      	int n = s . size ( ) ;
        for ( int i = 0 ; i < n ; i ++ ) {
            if ( s [ i ] < 0 ) {
                y = abs ( s [ i ] ) ;
                for ( int j = 0 ; j < n ; j ++ ) {
                    if ( s [ j ] == y ) {
                        if ( j > i ) {
                            x += ( i + j - 1 ) ;
                            s . erase ( s . begin ( ) + j ) ;
                            s . erase ( s . begin ( ) + i ) ;
                        }
                        else {
                            x += ( i + j ) ;
                            s . erase ( s . begin ( ) + i ) ;
                            s . erase ( s . begin ( ) + j ) ;
                        }
                        break ;
                    }
                }
                break ;
            }
        }
    }
  	return x ;
} 

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:12:9: warning: unused variable 'n' [-Wunused-variable]
     int n = 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...