8 条题解

  • 3

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<cctype>
    #include<algorithm>
    #include<stack>
    #include<queue>
    #include<vector>
    #include<map>
    #define INF 2147483647
    #define LL long long
    #define ULL unsigned long long
    #define MAXN 10005
    using namespace std;
    inline int read()
    {
    char ch=getchar();
    int x=0,f=1;
    while(!isdigit(ch))
    {
    if(ch=='-') f=-1;
    ch=getchar();
    }
    while(isdigit(ch))
    {
    x=x*10+ch-'0';
    ch=getchar();
    }
    return x*f;
    }
    struct Edge{
    int v,w;
    Edge(int v=0,int w=0):v(v),w(w){}

    };
    struct Node{
    int id;
    LL d;
    Node(int id=0,LL d=0):id(id),d(d){}
    bool operator <(const Node& n1)const{
    return d>n1.d;
    }
    };
    vector<Edge> adj[500005];
    priority_queue<Node> q;
    int n,m,s;
    LL d[MAXN];
    bool vis[MAXN];
    void dijkstra(int st)
    {
    for(int i=1;i<=n;i++) d[i]=INF;
    d[st]=0;
    int u=0,v=0,w=0;
    q.push(Node(st,0));
    while(!q.empty())
    {
    u=q.top().id;
    q.pop();
    if(vis[u]) continue;
    vis[u]=1;

    int len=adj[u].size();
    for(int i=0;i<len;i++)
    {
    v=adj[u][i].v;
    w=adj[u][i].w;
    if(d[u]+w<d[v])
    {
    d[v]=d[u]+w;
    q.push(Node(v,d[v]));
    }
    }
    }
    }
    int aa,bb;
    int main()
    {
    aa=read();
    bb=read();
    n=3;
    adj[1].push_back(Edge(2,aa));
    adj[2].push_back(Edge(3,bb));
    dijkstra(1);
    printf("%lld",d[3]);
    return 0;
    }

    //不适合高精度:)

  • 0

    #include <iostream>
    using namespace std;
    int main()
    {
    int x,y;
    cin>>x>>y;
    cout<<x+y;
    return 0;
    }

  • 0
    @ 2021-11-17 17:30:40

    #include<iostream>
    using namespace std;
    int main()
    {
    int x,y;
    cin>>x>>y;
    cout<<x+y<<endl;
    return 0;
    }

  • 0

    #include<iostream>
    using namespace std;
    int main()
    {
    int x,y;
    cin>>x>>y;
    cout<<x+y<<endl;
    return 0;
    }
    //nice

  • -1
    @ 2021-11-21 21:14:33

    #include <iostream>
    using namespace std;
    int main()
    {
    int x,y;
    cin>>x>>y;
    cout<<x+y;
    return 0;
    }

  • -2

    #include<iostream>
    using namespace std;
    int main()
    {
    int x,y;
    cin>>x>>y;
    cout<<x+y<<endl;

    return 0;

    }

  • -2
    @ 2021-11-15 09:56:06

    #include<iostream>
    using namespace std;
    int main()
    {
    int x,y;
    cin>>x>>y;
    cout<<x+y;
    return 0;
    }
    //简单

  • -3

    #include<iostream>
    using namespace std;
    int main()
    {
    int a,b;
    cin>>a>>b;
    cout<<a+b;
    return 0;
    }

  • 1

信息

ID
1207
难度
8
分类
(无)
标签
递交数
3905
已通过
317
通过率
8%
上传者