Submission #1081016

# Submission time Handle Problem Language Result Execution time Memory
1081016 2024-08-29T16:59:54 Z raphaelp Text editor (CEOI24_editor) C++14
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long N;
    cin >> N;
    long long debx, deby, finx, finy;
    cin >> debx >> deby >> finx >> finy;
    debx--, deby--, finx--, finy--;
    vector<long long> Tab(N);
    map<long long, long long> M;
    vector<long long> ys;
    for (long long i = 0; i < N; i++)
    {
        cin >> Tab[i];
        ys.push_back(Tab[i]);
    }
    ys.push_back(deby);
    ys.push_back(finy);
    long long buff = 0;
    sort(ys.begin(), ys.end());
    for (long long i = 0; i < ys.size(); i++)
        if (i == 0 || ys[i] != ys[i - 1])
            M[ys[i]] = buff++;
    deby = M[deby];
    finy = M[finy];
    for (long long i = 0; i < N; i++)
        Tab[i] = M[Tab[i]];
    vector<vector<long long>> occ(N, vector<long long>(buff + 1));
    priority_queue<vector<long long>> PQ;
    PQ.push({0, debx, deby});
    while (!PQ.empty())
    {
        long long x = PQ.top()[1], y = PQ.top()[2], t = PQ.top()[0];
        PQ.pop();
        if (occ[x][y])
            continue;
        occ[x][y] = 1;
        if (x == finx && y == finy)
        {
            cout << -t;
            return 0;
        }
        if (y > 0)
            PQ.push({t - (ys[y] - ys[y - 1]), x, y - 1});
        if (y < Tab[x])
            PQ.push({t - (ys[y + 1] - ys[y]), x, y + 1});
        if (x > 0 && y == 0)
            PQ.push({t - 1, x - 1, Tab[x - 1]});
        if (x < N - 1 && y == Tab[x])
            PQ.push({t - 1, x + 1, 0});
        if (x < N - 1)
            PQ.push({t - 1, x + 1, min(y, Tab[x + 1])});
        if (x > 0)
            PQ.push({t - 1, x - 1, min(y, Tab[x - 1])});
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:22:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (long long i = 0; i < ys.size(); i++)
      |                           ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -