# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1107300 | 2024-11-01T05:58:42 Z | debugDragon | Parking Problem (innopolis2021_final_A) | C++14 | 2000 ms | 888 KB |
#include <iostream> #include <string> #include <vector> using namespace std; void solveSubtask1(const string& parkingLine, const string& queue) { int n = parkingLine.size(); int m = queue.size(); vector<char> parking(n, '.'); // Initialize parking as vacant string result; // Check if Paulina can park without anyone from the queue entering bool canParkInitially = (n >= 2); result += (canParkInitially ? 'Y' : 'N'); for (char vehicle : queue) { if (vehicle == 'M') { // Park a motorcycle in a single vacant spot for (int i = 0; i < n; ++i) { if (parking[i] == '.') { parking[i] = 'X'; break; } } } else if (vehicle == 'C') { // Park a car in two adjacent vacant spots bool parked = false; for (int i = 0; i + 1 < n; ++i) { if (parking[i] == '.' && parking[i + 1] == '.') { parking[i] = 'X'; parking[i + 1] = 'X'; parked = true; break; } } if (!parked) break; // No more space for cars } // Check if there are still two adjacent vacant spots for Paulina bool canPark = false; for (int i = 0; i + 1 < n; ++i) { if (parking[i] == '.' && parking[i + 1] == '.') { canPark = true; break; } } result += (canPark ? 'Y' : 'N'); } cout << result << endl; } int main() { int t; cin >> t; while (t--) { string parkingLine, queue; cin >> parkingLine >> queue; solveSubtask1(parkingLine, queue); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2065 ms | 836 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2047 ms | 752 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2055 ms | 888 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2065 ms | 836 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |