Task: | Robotti |
Sender: | Username* |
Submission time: | 2024-10-28 12:25:14 +0200 |
Language: | C++ |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:13:16: error: 'numeric_limits' was not declared in this scope 13 | cin.ignore(numeric_limits<streamsize>::max(), '\n'); | ^~~~~~~~~~~~~~ input/code.cpp:13:41: error: expected primary-expression before '>' token 13 | cin.ignore(numeric_limits<streamsize>::max(), '\n'); | ^ input/code.cpp:13:47: error: no matching function for call to 'max()' 13 | cin.ignore(numeric_limits<streamsize>::max(), '\n'); | ~~~~~^~ In file included from /usr/include/c++/11/vector:60, from input/code.cpp:1: /usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)' 254 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: input/...
Code
#include <vector> #include <algorithm> #include <iostream> #include <cmath> #include <string> using namespace std; int main() { int n; cin >> n; cin.ignore(numeric_limits<streamsize>::max(), '\n'); string line; getline(cin, line); size_t robot = line.find('R'); //cout << line << "\n"; //cout << robot << "\n"; vector<int> offsets; int pos = 0; int robpos = 0; for (char room : line) { if (room == '*') { offsets.push_back(pos - robot); } else if (room == 'R') { //offsets.push_back(0); robpos = offsets.size()-1; } pos++; } cout << 1 << 2 << "\n"; return 0; int totalscore = 0; int steps = 0; int roboff = 0; while (offsets.size() > 0) { /*cout << "\n"; for (int off : offsets) { cout << off << " "; } cout << "\nstep:";*/ int left = offsets[robpos] - roboff; int right = offsets[robpos+1] - roboff; if (abs(left) > abs(right)) { //cout << " right " << left << " " << right; offsets.erase(offsets.begin()+robpos+1); roboff += right; steps += abs(right); totalscore++; } else if (abs(right) > abs(left)){ //cout << " left " << left << " " << right; offsets.erase(offsets.begin()+robpos); robpos -= 1; roboff += left; steps += abs(left); totalscore++; } else { //cout << "same" << "\n"; break; } } cout << steps << " " << totalscore << "\n"; return 0; }