제출 #626586

#제출 시각아이디문제언어결과실행 시간메모리
626586TrunktyArranging Shoes (IOI19_shoes)C++14
45 / 100
321 ms146532 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; //#define int ll #include "shoes.h" ll cnt,ans; deque<ll> shoes[200005]; ll arr[200005]; deque<ll> countinv(deque<ll> x){ if(x.size()==1){ return x; } ll mid = x.size()/2LL-1LL; deque<ll> a,b,c; for(ll i=0;i<=mid;i++){ a.push_back(x[i]); } for(ll i=mid+1;i<x.size();i++){ b.push_back(x[i]); } a = countinv(a); b = countinv(b); while(a.size()>0){ int i = a.back(); while(b.size()>0 and b.back()>i){ c.push_front(b.back()); b.pop_back(); } ans += b.size(); c.push_front(i); a.pop_back(); } while(b.size()>0){ c.push_front(b.back()); b.pop_back(); } return c; } ll count_swaps(vector<int> s){ for(ll i=0;i<s.size();i++){ if(s[i]<0){ cnt += 2; arr[i+1] = cnt-1; shoes[-s[i]].push_back(cnt); } } for(ll i=0;i<s.size();i++){ if(s[i]>0){ arr[i+1] = shoes[s[i]].front(); shoes[s[i]].pop_front(); } } deque<ll> dq; for(int i=1;i<=s.size();i++){ dq.push_back(arr[i]); } countinv(dq); return ans; }

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

shoes.cpp: In function 'std::deque<long long int> countinv(std::deque<long long int>)':
shoes.cpp:21:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for(ll i=mid+1;i<x.size();i++){
      |                 ~^~~~~~~~~
shoes.cpp: In function 'll count_swaps(std::vector<int>)':
shoes.cpp:44:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  for(ll i=0;i<s.size();i++){
      |             ~^~~~~~~~~
shoes.cpp:51:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |  for(ll i=0;i<s.size();i++){
      |             ~^~~~~~~~~
shoes.cpp:58:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |  for(int i=1;i<=s.size();i++){
      |              ~^~~~~~~~~~
#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...