7.3日总结

发布时间 2023-07-03 20:59:44作者: 临江柔

一、完成了pta实验报告1000+积分。

二、考驾照科一刷题。

三、复习了图论的dijlstra算法

 

#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
typedef pair<int, int >p;
const int N = 100010;
int  n, m;
int d[N];
bool st[N];
int idx, ne[N], e[N], w[N], h[N];
void add(int a, int b, int c)
{
    e[idx] = b, w[idx] = c, ne[idx] = h[a], idx++;
}
int dijkstra()
{
    memset(d, 0x3f, sizeof d);
    d[1] = 0;
    priority_queue<p, vector<p>, greater<p>>heap;
    heap.push({ 0,1 });
    while (heap.size())
    {
        p t = heap.top();
        heap.pop();
        int ve = t.second, dist = t.first;
        if (st[ve])continue;
        st[ve] = 1;
        for (int i = h[ve];i != -1;i = ne[i])
        {
            int j = e[i];
            if (d[j] > dist + w[i])
            {
                d[j] = dist + w[i];
                heap.push({ d[j],j });
            }
        }
    }
    if (d[n] == 0x3f3f3f3f)return -1;
    return d[n];
}
int main()
{
    cin >> n >> m;
    memset(h, -1, sizeof h);
    while (m--)
    {
        int a, b, c;
        cin >> a >> b >> c;
        add(a, b, c);
    }
    int t = dijkstra();
    cout << t << endl;
    return 0;
}

 

四、问题,遇见了数位dp的题,明天打算学一下数位dp,然后把java的字符串之前的知识过完并复习一遍,练几个练习题。然后科一刷题。