제출 #644406

#제출 시각아이디문제언어결과실행 시간메모리
644406a_aguiloArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; int N; void change(int index, int delta, int BIT[]){ for(; index <N; index += (index&(-index))){ BIT[index]+=delta; } } int query(int index, int BIT[]){ int ans = 0; for(; index > 0; index -= (index&(-index))) ans+= BIT[index]; return ans; } long long count_swaps(vector<int> s) { map<int, queue<int>> M; N = s.size()+1; int BIT[N]; memset(BIT, 0, sizeof(BIT)); for(int i = 1; i < N; ++i) change(i, 1, BIT); long long ans = 0; for(int i = 0; i < s.size(); ++i){ //cout << i << " " << ans << endl; if(M.find(-s[i]) == M.end()){ if(M.find(s[i]) == M.end()){ M[s[i]] = {i}; } else if(M[s[i]].empty()){ M[s[i]] = {i}; } else{ M[s[i]].push(i); } } else if(M[-s[i]].empty()){ if(M.find(s[i]) == M.end()){ M[s[i]] = {i}; } else if(M[s[i]].empty()){ M[s[i]] = {i}; } else{ M[s[i]].push(i); } } else{ if(s[i] < 0) ans++; //cout << "a "; int prev = M[-s[i]].front(); //cout <<"b "; M[-s[i]].pop(); //cout <<"c "; ans += (long long)query(i, BIT)-(long long)query(prev+1, BIT); //cout <<"d "; change(i+1, -1, BIT); //cout << "e "; change(prev+1, 1, BIT); } } return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i = 0; i < s.size(); ++i){
      |                    ~~^~~~~~~~~~
shoes.cpp:31:29: error: no match for 'operator=' (operand types are 'std::map<int, std::queue<int> >::mapped_type' {aka 'std::queue<int>'} and '<brace-enclosed initializer list>')
   31 |                 M[s[i]] = {i};
      |                             ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from shoes.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:96:11: note: candidate: 'std::queue<int>& std::queue<int>::operator=(const std::queue<int>&)'
   96 |     class queue
      |           ^~~~~
/usr/include/c++/10/bits/stl_queue.h:96:11: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::queue<int>&'
/usr/include/c++/10/bits/stl_queue.h:96:11: note: candidate: 'std::queue<int>& std::queue<int>::operator=(std::queue<int>&&)'
/usr/include/c++/10/bits/stl_queue.h:96:11: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<int>&&'
shoes.cpp:34:29: error: no match for 'operator=' (operand types are 'std::map<int, std::queue<int> >::mapped_type' {aka 'std::queue<int>'} and '<brace-enclosed initializer list>')
   34 |                 M[s[i]] = {i};
      |                             ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from shoes.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:96:11: note: candidate: 'std::queue<int>& std::queue<int>::operator=(const std::queue<int>&)'
   96 |     class queue
      |           ^~~~~
/usr/include/c++/10/bits/stl_queue.h:96:11: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::queue<int>&'
/usr/include/c++/10/bits/stl_queue.h:96:11: note: candidate: 'std::queue<int>& std::queue<int>::operator=(std::queue<int>&&)'
/usr/include/c++/10/bits/stl_queue.h:96:11: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<int>&&'
shoes.cpp:42:29: error: no match for 'operator=' (operand types are 'std::map<int, std::queue<int> >::mapped_type' {aka 'std::queue<int>'} and '<brace-enclosed initializer list>')
   42 |                 M[s[i]] = {i};
      |                             ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from shoes.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:96:11: note: candidate: 'std::queue<int>& std::queue<int>::operator=(const std::queue<int>&)'
   96 |     class queue
      |           ^~~~~
/usr/include/c++/10/bits/stl_queue.h:96:11: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::queue<int>&'
/usr/include/c++/10/bits/stl_queue.h:96:11: note: candidate: 'std::queue<int>& std::queue<int>::operator=(std::queue<int>&&)'
/usr/include/c++/10/bits/stl_queue.h:96:11: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<int>&&'
shoes.cpp:45:29: error: no match for 'operator=' (operand types are 'std::map<int, std::queue<int> >::mapped_type' {aka 'std::queue<int>'} and '<brace-enclosed initializer list>')
   45 |                 M[s[i]] = {i};
      |                             ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from shoes.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:96:11: note: candidate: 'std::queue<int>& std::queue<int>::operator=(const std::queue<int>&)'
   96 |     class queue
      |           ^~~~~
/usr/include/c++/10/bits/stl_queue.h:96:11: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::queue<int>&'
/usr/include/c++/10/bits/stl_queue.h:96:11: note: candidate: 'std::queue<int>& std::queue<int>::operator=(std::queue<int>&&)'
/usr/include/c++/10/bits/stl_queue.h:96:11: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<int>&&'