# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1107291 | 2024-11-01T05:54:17 Z | debugDragon | Parking Problem (innopolis2021_final_A) | C++14 | 2000 ms | 756 KB |
#include <iostream> #include <vector> #include <string> using namespace std; bool canParkCar(const vector<char>& parking) { // Check if there are any two adjacent vacant spots for (size_t i = 0; i + 1 < parking.size(); ++i) { if (parking[i] == '.' && parking[i + 1] == '.') { return true; } } return false; } void solveTestCase(const string& parkingLine, const string& queue) { int n = parkingLine.size(); int m = queue.size(); vector<char> parking(parkingLine.begin(), parkingLine.end()); string result; // Check if Paulina can park without anyone from the queue entering result += (canParkCar(parking) ? 'Y' : 'N'); for (char vehicle : queue) { // Update the parking state based on the vehicle in the 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 for (int i = 0; i + 1 < n; ++i) { if (parking[i] == '.' && parking[i + 1] == '.') { parking[i] = 'X'; parking[i + 1] = 'X'; break; } } } // Check if Paulina can park after this vehicle enters result += (canParkCar(parking) ? 'Y' : 'N'); } cout << result << endl; } int main() { int t; cin >> t; while (t--) { string parkingLine, queue; cin >> parkingLine >> queue; solveTestCase(parkingLine, queue); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2068 ms | 720 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2043 ms | 684 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2061 ms | 756 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2068 ms | 720 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |