제출 #231722

#제출 시각아이디문제언어결과실행 시간메모리
231722mohamedsobhi777Arranging Shoes (IOI19_shoes)C++14
10 / 100
40 ms3320 KiB
#include<bits/stdc++.h> #include "shoes.h" using namespace std ; const int N =1e5 + 7 ; int n; long long count_swaps(std::vector<int> s) { int val = abs(s[0]) ; n = s.size() ; int ret = 0 ; for(int i = 0 ; i < n ;i++){ s[i] = (s[i] > 0) ; } deque<int> dq ; int l = 1 ; int x = 0 ; for(int i = 0 ;i < n;i++){ if(s[i] == 1 - l){ ret+= abs(i - x++) ; l = 1 - l ; } else{ dq.push_back(i) ; } while(dq.size() && s[dq.front()] == 1 - l){ ret+=abs(dq.front() - x++) ; dq.pop_front() ; l = 1 - l ; } } return ret / 2; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:11:13: warning: unused variable 'val' [-Wunused-variable]
         int val = abs(s[0]) ;   
             ^~~
#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...