제출 #312204

#제출 시각아이디문제언어결과실행 시간메모리
312204tjdgus4384Arranging Shoes (IOI19_shoes)C++14
100 / 100
251 ms141200 KiB
#include<bits/stdc++.h> using namespace std; deque<int> vp[100001], vm[100001], v, v2; long long merge_sort(int x, int y){ if(x == y) return 0; int mid = (x+y)/2; long long ret = merge_sort(x, mid) + merge_sort(mid+1, y); int f = x, s = mid+1; vector<int> newv; while(f <= mid && s <= y){ if(v2[f] <= v2[s]){ newv.push_back(v2[f]); f++; } else { newv.push_back(v2[s]); ret += mid - f + 1; s++; } } for(int i = f;i <= mid;i++) newv.push_back(v2[i]); for(int i = s;i <= y;i++) newv.push_back(v2[i]); for(int i = x;i <= y;i++) v2[i] = newv[i - x]; return ret; } long long count_swaps(vector<int> S){ for(int i = 0;i < S.size();i++){ if(S[i] < 0){ if(vp[-S[i]].empty()) vm[-S[i]].push_back(i); else{ v.push_back(i); v.push_back(vp[-S[i]].front()); vp[-S[i]].pop_front(); } } if(S[i] > 0){ if(vm[S[i]].empty()) vp[S[i]].push_back(i); else{ v.push_back(vm[S[i]].front()); v.push_back(i); vm[S[i]].pop_front(); } } } for(int i = 0;i < v.size();i++) v2.push_back(v[i]); return merge_sort(0, v2.size()-1); }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:29:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i = 0;i < S.size();i++){
      |                   ~~^~~~~~~~~~
shoes.cpp:47:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for(int i = 0;i < v.size();i++) v2.push_back(v[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...