Submission #1075509

#TimeUsernameProblemLanguageResultExecution timeMemory
1075509mindiyakArranging Shoes (IOI19_shoes)C++14
10 / 100
93 ms135024 KiB
#include "shoes.h" #include <vector> #include <deque> #include <iostream> #define ll long long #define F first #define S second using namespace std; long long count_swaps(std::vector<int> s) { ll ans = 0; ll cnt = 0; vector<deque<pair<int,int>>> arr(2e5+10); for(int i = 0;i<s.size();i++){ int left = 0; if(s[i] < 0)left = 1; // if(left)cerr << "left "; // else cerr << "right "; cerr << s[i] << " " << arr[-s[i]+1e5].size() << " "; if(arr[-s[i]+1e5].size() > 0){ auto a = arr[-s[i]+1e5][0]; arr[-s[i]+1e5].pop_front(); cnt --; // cerr << a.F << " " << a.S << " " << cnt << endl; ans += i - a.F - (cnt - a.S); if(left == 0)ans -= 1; }else{ // cerr << s[i]+1e5 << " " << i << " " << cnt << endl; arr[s[i]+1e5].push_back({i,cnt}); cnt ++; } } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:17:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for(int i = 0;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...