Submission #1107290

# Submission time Handle Problem Language Result Execution time Memory
1107290 2024-11-01T05:53:30 Z debugDragon Parking Problem (innopolis2021_final_A) C++14
0 / 100
2000 ms 1380 KB
#include <iostream>
#include <vector>
#include <string>

using namespace std;

bool canParkCar(const vector<char>& parking) {
    
    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;

 
    result += (canParkCar(parking) ? 'Y' : 'N');

    for (char vehicle : queue) {
        
        if (vehicle == 'M') {
            
            for (int i = 0; i < n; ++i) {
                if (parking[i] == '.') {
                    parking[i] = 'X';
                    break;
                }
            }
        } else if (vehicle == 'C') {
          
            for (int i = 0; i + 1 < n; ++i) {
                if (parking[i] == '.' && parking[i + 1] == '.') {
                    parking[i] = 'X';
                    parking[i + 1] = 'X';
                    break;
                }
            }
        }

       
        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

Main.cpp: In function 'void solveTestCase(const string&, const string&)':
Main.cpp:19:9: warning: unused variable 'm' [-Wunused-variable]
   19 |     int m = queue.size();
      |         ^
# Verdict Execution time Memory Grader output
1 Execution timed out 2062 ms 1164 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2053 ms 1316 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2056 ms 1380 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2062 ms 1164 KB Time limit exceeded
2 Halted 0 ms 0 KB -