Task: | Robotti |
Sender: | jokeri2222 |
Submission time: | 2024-10-29 12:49:29 +0200 |
Language: | C++ (C++11) |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp:2:1: error: extended character is not valid in an identifier 2 | | ^ input/code.cpp:4:1: error: extended character is not valid in an identifier 4 | | ^ input/code.cpp:6:1: error: extended character is not valid in an identifier 6 | int _len; | ^ input/code.cpp:6:3: error: extended character is not valid in an identifier 6 | int _len; | ^ input/code.cpp:7:1: error: extended character is not valid in an identifier 7 | string s; | ^ input/code.cpp:7:3: error: extended character is not valid in an identifier 7 | string s; | ^ input/code.cpp:8:1: error: extended character is not valid in an identifier 8 | cin >> _len; | ^ input/code.cpp:8:3: error: extended character is not valid in an identifier 8 | cin >> _len; | ^ input/code.cpp:9:1: error: extended character is not valid in an identifier 9 | cin >> s; |...
Code
#include <iostream> using namespace std; int main() { int _len; string s; cin >> _len; cin >> s; int index = s.find("R", 0); int steps = 0, coins = 0; int min_left = 1, min_right = 1; while (true) { int _left = _len, _right = _len; for (int i = index - min_left; i >= 0; --i) { if (s[i] == '*') { _left = index - i; break; } } for (int i = index + min_right; i < _len; ++i) { if (s[i] == '*') { _right = i - index; break; } } if (_left < _right) { steps += _left; coins++; s[index] = '.'; index -= _left; s[index] = 'R'; min_right = _right+_left-1; min_left = 1; } else if (_right < _left) { steps += _right; coins++; s[index] = '.'; index += _right; min_left = _right+_left-1; min_right = 1; s[index] = 'R'; } else { break; } } cout << steps << " " << coins << "\n"; return 0; }