제출 #210995

#제출 시각아이디문제언어결과실행 시간메모리
2109952qbingxuanArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
//#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { { int cnt = 0; vector<int> id(s.size()); map<int,vector<int>> mp; for(int i = 0; i < n; i++) { mp[s[i]].push_back(i); } for(int i = 0; i < n; i++) { if(id[i]) continue; int S = abs(s[i]); int a = mp[S].front(), b = mp[-S].front(); id[a] = ++cnt, id[b] = ++cnt; mp[S].pop_front(), mp[-S].pop_front(); } s = id; } //for(int x: s) cout << x << ' '; cout << '\n'; std::reverse(s.begin(), s.end()); std::vector<int> BIT(s.size()+1); auto query = [&BIT](int p){ int res = 0; for(; p>0; p-=p&-p) res += BIT[p]; return res; }; auto add = [&BIT](int p){ for(; p<BIT.size(); p+=p&-p) ++BIT[p]; }; long long ans = 0; for(int x: s) ans += query(x-1), add(x); return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:11:28: error: 'n' was not declared in this scope
         for(int i = 0; i < n; i++) {
                            ^
shoes.cpp:14:28: error: 'n' was not declared in this scope
         for(int i = 0; i < n; i++) {
                            ^
shoes.cpp:19:19: error: 'std::map<int, std::vector<int> >::mapped_type {aka class std::vector<int>}' has no member named 'pop_front'; did you mean 'front'?
             mp[S].pop_front(), mp[-S].pop_front();
                   ^~~~~~~~~
                   front
shoes.cpp:19:39: error: 'std::map<int, std::vector<int> >::mapped_type {aka class std::vector<int>}' has no member named 'pop_front'; did you mean 'front'?
             mp[S].pop_front(), mp[-S].pop_front();
                                       ^~~~~~~~~
                                       front
shoes.cpp: In lambda function:
shoes.cpp:32:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(; p<BIT.size(); p+=p&-p) ++BIT[p];
               ~^~~~~~~~~~~