제출 #296604

#제출 시각아이디문제언어결과실행 시간메모리
296604zoooma13Arranging Shoes (IOI19_shoes)C++14
50 / 100
1094 ms24184 KiB
#include "bits/stdc++.h" #include "shoes.h" using namespace std; vector <bool> st; int qry(int l ,int r){ int ret = 0; for(int i=l; i<=r; i++) ret += !st[i]; return ret; } long long count_swaps(vector<int> s) { st.resize(s.size()); map <int ,vector<int>> mp; for(int i=(int)s.size()-1; ~i; i--) mp[s[i]].push_back(i); long long ans = 0; for(int i=0; i<s.size(); i++) if(!st[i]){ int x = s[i]; mp[x].pop_back(); int y_idx = mp[-x].back(); mp[-x].pop_back(); st[i] = 1 ,st[y_idx] = 1; ans += qry(i+1 ,y_idx-1)+(x > 0); } return ans; }

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

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