Submission #845322

# Submission time Handle Problem Language Result Execution time Memory
845322 2023-09-06T13:10:05 Z M_W_13 Trampoline (info1cup20_trampoline) C++17
0 / 100
2000 ms 13308 KB
#include <iostream>
#include <vector>
using namespace std;
int r, c, n;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> r >> c >> n;
    vector <vector <int>> zielone;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        zielone.push_back({});
        zielone[i].push_back(a);
        zielone[i].push_back(b);
    }
    int jaki[n];
    for (int i = 0; i < n; i++) {
        jaki[i] = -1;
        for (int j = 0; j < n; j++) {
            if (zielone[j][0] == zielone[i][0] + 1 && zielone[j][1] >= zielone[i][1]) {
                if (jaki[i] == -1) {
                    jaki[i] = j;
                }
                else {
                    if (zielone[j][1] < zielone[jaki[i]][1]) {
                        jaki[i] = j;
                    }
                }
            }
        }
    }
    int t;
    cin >> t;
    for (int pyt = 0; pyt < t; pyt++) {
        int x, y, x2, y2;
        cin >> x >> y >> x2 >> y2;
        int x_s = x;
        int a = -1, b;
        int pole = -1;
        for (int i = 0; i < n; i++) {
            if (zielone[i][0] == x && zielone[i][1] >= y) {
                if (a == - 1 || zielone[i][1] < b) {
                    a = zielone[i][0];
                    b = zielone[i][1];
                    pole = i;
                }
            }
        }
        if (x == x2 && y <= y2) {
            cout << "Yes" << endl;
        }
        else if (a == -1) {
            cout << "No" << endl;
        }
        else {
            x = a; y = b;
            while (x < x2 && y <= y2) {
                if (jaki[pole] == -1) {
                    break;
                }
                else {
                    x = zielone[jaki[pole]][0] + 1; y = zielone[jaki[pole]][1];
                    pole = jaki[pole];
                }
            }
            if ((x == x2 || (x - 1 == x2 && x != a)) && y <= y2) {
                cout << "Yes" << endl;
            }
            else {
                cout << x << " " << y;
                cout << "No" << endl;
            }
        }
    }
    return 0;
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:38:13: warning: unused variable 'x_s' [-Wunused-variable]
   38 |         int x_s = x;
      |             ^~~
trampoline.cpp:43:30: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |                 if (a == - 1 || zielone[i][1] < b) {
      |                     ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 1112 KB YES or NO expected, but 175 found [2nd token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2045 ms 12556 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2048 ms 13308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 848 KB YES or NO expected, but 999755739 found [2nd token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2041 ms 13048 KB Time limit exceeded
2 Halted 0 ms 0 KB -