QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#274304#7883. Takeout DeliveringCSUST_GXL#WA 102ms23180kbC++201.4kb2023-12-03 14:03:572023-12-03 14:03:59

Judging History

你现在查看的是最新测评结果

  • [2023-12-03 14:03:59]
  • 评测
  • 测评结果:WA
  • 用时:102ms
  • 内存:23180kb
  • [2023-12-03 14:03:57]
  • 提交

answer

#include<bits/stdc++.h>
//#define int long long
#define endl '\n'
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=3e5+5;
vector<pair<int,int>>e[maxn];
bool vis[maxn][2];
int dis[maxn][2];
struct node{
    int id,val;
    friend bool operator <(node a,node b){
        a.val>b.val;
    }
};
int s;
void dij(int ss){
    queue<node>q;
    dis[ss][s]=0;
    q.push({ss,0});
    while(!q.empty()){
        auto [u,val]=q.front();
        q.pop();
        if(vis[u][s])continue;
        vis[u][s]=true;
        for(auto [v,w]:e[u]){
            if(vis[v][s])continue;
            if(dis[v][s]>max(dis[u][s],w)){
                dis[v][s]=max(dis[u][s],w);
                q.push({v,dis[v][s]});
            }
        }
    }
}
void solve(){
    int n,m;
    cin>>n>>m;
    int res=2e9+7;
    memset(dis,0x3f,sizeof dis);
    for(int i=1;i<=m;i++){
        int u,v,w;
        cin>>u>>v>>w;
        if(u>v)swap(u,v);
        if(u==1&&v==n)res=w;
        e[u].push_back({v,w});
        e[v].push_back({u,w});
    }
    s=0;
    dij(1);
    s=1;
    dij(n);
    for(int i=2;i<n;i++){
        res=min(res,dis[i][0]+dis[i][1]);
//        cout<<dis[i][0]<<" "<<dis[i][1]<<endl;
    }
    cout<<res<<endl;
}
signed main(){
    int t=1;
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    while(t--){
        solve();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 13580kb

input:

4 6
1 2 2
1 3 4
1 4 7
2 3 1
2 4 3
3 4 9

output:

5

result:

ok 1 number(s): "5"

Test #2:

score: -100
Wrong Answer
time: 102ms
memory: 23180kb

input:

300000 299999
80516 80517 597830404
110190 110191 82173886
218008 218009 954561262
250110 250111 942489774
66540 66541 156425292
34947 34948 239499776
273789 273790 453201232
84428 84429 439418398
98599 98600 326095035
55636 55637 355015760
158611 158612 684292473
43331 43332 43265001
171621 171622 ...

output:

1356916107

result:

wrong answer 1st numbers differ - expected: '1999991697', found: '1356916107'