Submission #626576

#TimeUsernameProblemLanguageResultExecution timeMemory
626576TrunktyArranging Shoes (IOI19_shoes)C++14
10 / 100
332 ms155416 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; //#define int ll #include "shoes.h" ll cnt,ans; deque<ll> shoes[100005]; ll arr[100005]; 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; }

Compilation message (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...