Submission #985454

# Submission time Handle Problem Language Result Execution time Memory
985454 2024-05-17T21:26:57 Z islam998 Food Court (JOI21_foodcourt) C++17
0 / 100
736 ms 524288 KB
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    
    vector<queue<int>> shops(N);  // Vector of queues to represent customers in each shop
    vector<int> results;          // Vector to store the results of "Service" events

    for (int i = 0; i < Q; ++i) {
        int T;
        cin >> T;
        
        if (T == 1) {  // Join event
            int L, R, C, K;
            cin >> L >> R >> C >> K;
            for (int j = L - 1; j < R; ++j) {
                for (int k = 0; k < K; ++k) {
                    shops[j].push(C);
                }
            }
        } else if (T == 2) {  // Leave event
            int L, R, K;
            cin >> L >> R >> K;
            for (int j = L - 1; j < R; ++j) {
                for (int k = 0; k < K && !shops[j].empty(); ++k) {
                    shops[j].pop();
                }
            }
        } else if (T == 3) {  // Service event
            int A, B;
            cin >> A >> B;
            if (B <= shops[A - 1].size()) {
                queue<int> tempQueue;
                for (int j = 1; j < B; ++j) {
                    tempQueue.push(shops[A - 1].front());
                    shops[A - 1].pop();
                }
                int group = shops[A - 1].front();
                results.push_back(group);
                while (!tempQueue.empty()) {
                    shops[A - 1].push(tempQueue.front());
                    tempQueue.pop();
                }
            } else {
                results.push_back(0);
            }
        }
    }
    
    // Print all results of "Service" events
    for (int result : results) {
        cout << result << endl;
    }

    return 0;
}

Compilation message

foodcourt.cpp: In function 'int main()':
foodcourt.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::queue<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |             if (B <= shops[A - 1].size()) {
      |                 ~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 731 ms 45964 KB Output is correct
2 Correct 548 ms 45392 KB Output is correct
3 Correct 726 ms 45572 KB Output is correct
4 Correct 736 ms 45688 KB Output is correct
5 Correct 557 ms 45580 KB Output is correct
6 Correct 588 ms 45688 KB Output is correct
7 Incorrect 57 ms 1404 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 520 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 523 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1628 KB Output isn't correct
2 Halted 0 ms 0 KB -