제출 #1075509

#제출 시각아이디문제언어결과실행 시간메모리
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; }

컴파일 시 표준 에러 (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...