全部评论 62

  • 给出一个有N个节点的单链表,从头向尾输出删除M个节点后的链表。
    【输入格式】
    第一行一个整数n。(n≤100000)
    接下来n行,每行的格式是:id val nxt,分别表示新加入的人的编号、节点存储的值、下个节点的编号。 nxt的值为-1时表示下个节点为空,头节点编号为1。
    第n+2行一个整数m(m≤n)。
    接下来m行每行一个整数,分别表示要删除的节点的编号。
    【输出格式】
    从头向尾输出每个节点存储的值。
    【输入样例】
    4
    1 5 2
    2 3 3
    3 1 4
    4 2 -1
    1
    2
    【输出样例】
    5 1 2

    2025-06-20 来自 上海

    2
  • 在这个帖子的第2条评论,给我点点赞。(谢谢各位)

    2024-08-09 来自 浙江

    2
  • 网站地址

    图标编辑器:https://csacademy.com/app/graph_editor/
    画图:https://excalidraw.com/
    云剪辑版:https://paste.nugine.xyz/

    1周前 来自 浙江

    1
  • V50看看实力

    2024-08-10 来自 浙江

    1
  • 6

    2024-08-09 来自 广东

    1
  • ·暴力出奇迹,骗分过样例。

    ·数学先打表,DP看运气。

    ·穷举TLE,递推UKE。

    ·模拟MLE,贪心还CE。

    ·想要骗到分,就要有方法。

    ·图论背模板,数论背公式。

    ·动规背方程,高精背代码。

    ·如果都没背,干脆输样例。

    模拟只会猜题意,贪心只能过样例,

    数学上来先打表,D P一般看规律。

    组合数学靠运气,计算几何瞎暴力,

    图论一顿套模板,数论只会GCD。

    2024-08-09 来自 浙江

    1
  • 10
    5
    890 965 256 419 296 987 45 676 976 742

    2024-08-01 来自 湖南

    1
  • #include<bits/stdc++.h>
    using namespace std;
    int n,k,m,s,t,c[109],a[109][109],dis[109];
    bool vis[109];
    bool vc[109];
    vector<pair<int,int>> ve[109];
    bool good(int u,int v){
    int i=c[u];
    int j=c[v];
    if(vc[j]==1) return false;
    if(c[u]==c[v]) return false;
    for(int i=1;i<=n;i++){
    if(vc[c[i]]==1){
    if(a[c[v]][c[i]]==1)
    return false;
    if(c[v]==c[i])
    return false;
    }
    }
    return true;
    }
    void dijkstra(int s){
    memset(dis,0x3f,sizeof(dis));
    priority_queue<pair<int,int>> que;
    dis[s]=0;
    que.push({0,s});
    while(!que.empty()){
    int u=que.top().second;
    int v=que.top().first;
    que.pop();
    if(vis[u]==1) continue;
    vis[u]=1;
    vc[c[u]]=1;
    if(good(u,v)){
    for(auto vv:ve[u]){
    int v=vv.first;
    int w=vv.second;
    if(dis[v]>dis[u]+w){
    dis[v]=dis[u]+w;
    if(vis[v]==0){
    que.push({-dis[v],v});
    }
    }
    }
    }

    }
    

    }
    int main(){
    cin>>n>>k>>m>>s>>t;
    for(int i=1;i<=n;i++){
    cin>>c[i];
    }
    for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
    cin>>a[i][j];
    }
    }
    for(int k=1;k<=m;k++){
    int u,v,d;
    cin>>u>>v>>d;
    int i=c[u];
    int j=c[v];
    if(a[j][i]==0)
    ve[u].push_back({v,d});
    if(a[i][j]==0)
    ve[v].push_back({u,d});
    }
    dijkstra(s);
    if(dis[t]==0x3f3f3f3f){
    cout<<-1<<endl;
    }else{
    cout<<dis[t];
    }
    return 0;
    }

    4小时前 来自 浙江

    0
  • 4 1 5 2 6 3

    21小时前 来自 江苏

    0
  • #include<bits/stdc++.h>
    using namespace std;
    #define int long long
    int n,k,x,a[100005],b[100005],sum,p,q;
    bool check(int l){
    q=((n*k-l)/n)b[n];
    if(l%n==0)
    p=a[n];
    else
    p=b[n]-b[l%n-1];
    return q+p>=x;
    }
    signed main(){
    int t;
    cin>>t;
    while(t--){
    cin>>n>>k>>x;
    sum=0;
    for(int i=1;i<=n;++i){
    cin>>a[i];
    b[i]=a[i]+b[i-1];
    }
    //cout<<check(15);
    int l=1,r=n
    k,ans=0;
    while(l<=r){
    int mid=(l+r)>>1;
    if(check(mid)){
    ans=mid;
    l=mid+1;
    }
    else
    r=mid-1;
    }
    cout<<ans<<endl;
    }
    }

    22小时前 来自 河北

    0
  • vector<int>v(10,1);//该动态数组v的大小为10,每一项都被初始化为1

    6天前 来自 浙江

    0
  • 啊啊啊dust我喜欢你

    6天前 来自 浙江

    0
  • /😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱😱

    1周前 来自 上海

    0
  • #include<bits/stdc++.h>
    using namespace std;
    int main(){
        for (int i=1;i<=100;i++)cout<<"张老师真丑~";
    return 0;
    }
    

    1周前 来自 广东

    0
  • 5 4
    10 10 10 10
    9 8 9 6 5

    1周前 来自 上海

    0
  • #include<bits/stdc++.h>
    using namespace std;
    int main(){

    return 0;
    

    }

    1周前 来自 浙江

    0
  • road

    1周前 来自 河北

    0
  • #include <bits/stdc++.h>
    using namespace std;
    int main(){

    return 0;
    

    }

    2025-07-18 来自 浙江

    0
  • 把你们剪贴板中的内容发出来!!!

    2025-07-17 来自 福建

    0

热门讨论