Task: | Thieves and Prisons |
Sender: | Ingólfur Orri |
Submission time: | 2019-03-06 15:56:21 +0200 |
Language: | C++ |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:21:50: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)' if(find(cap.begin(), cap.end(), fangi) != cap.end()) { ^ In file included from /usr/include/c++/7/bits/locale_facets.h:48:0, from /usr/include/c++/7/bits/basic_ios.h:37, from /usr/include/c++/7/ios:44, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from input/code.cpp:1: /usr/include/c++/7/bits/streambuf_iterator.h:369:5: note: candidate: template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(std::istreambuf_iterator<_CharT>, std::istreambuf_iterator<_CharT>, const _CharT2&) find(istreambuf_iterator<_CharT> __first, ^~~~ /usr/include/c++/7/bits/stre...
Code
#include <iostream> #include <vector> using namespace std; int main() { int n, k, m; cin >> n >> k >> m; vector<int> fang; vector<int> cap; int pri = 0; bool top = false; for(int i = 0; i < m; i++) { string act; int fangi; cin >> act >> fangi; if(act == "C") { if(pri == n) top = true; if(find(cap.begin(), cap.end(), fangi) != cap.end()) { cout << "IMPOSSIBLE" << endl; return 0; } else cap.push_back(fangi); if(top) pri--; else pri++; if(pri == 1) top = false; fang.push_back(pri); } else if(act == "O") { if(pri == 0) { cout << "IMPOSSIBLE" << endl; return 0; } for(unsigned int j = 0; j < cap.size(); j++) { if(fangi == cap[j]) { cout << "IMPOSSIBLE" << endl; return 0; } } cap.pop_back(); fang.push_back(pri); pri--; if(pri < 0) pri = 0; } } for(unsigned int i = 0; i < fang.size(); i++) { cout << fang[i] << " "; } cout << endl; return 0; }