Help needed in classical Dijkstra algorithm

I came up with an implementation of Dijkstra from striver’s video.

vector<int> dijkstra(vector<vector<int>> adj[], int v, int src) {
    vector<int> ans(v, INT_MAX);
    ans[src] = 0;
    set<pair<int, int> > s;
    s.insert({0, src});
    while(s.size()) {
        auto p = *s.begin();

        int dis = p.first;
        int node = p.second;

        for (auto p: adj[node]) {
            int nbr = p[0], cost = p[1];
            if(dis + cost < ans[nbr]) {
                if(ans[nbr] != INT_MAX) s.erase({ans[nbr], nbr});
                ans[nbr] = dis + cost;
                s.insert({ans[nbr], nbr});
    return ans;

I think if the given graph contains negative edges, but does not contain any negative weight cycle, then this implementation will still give us correct shortest path distances.
But the dijkstra’s algorithm does not work with negative edge weights.
I am not able to find any case where the above code fails.

Please correct me if I am wrong?