QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#187981#2178. RobotLynkcat0 106ms99288kbC++201.8kb2023-09-25 10:23:462023-09-25 10:23:47

Judging History

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

  • [2023-09-25 10:23:47]
  • 评测
  • 测评结果:0
  • 用时:106ms
  • 内存:99288kb
  • [2023-09-25 10:23:46]
  • 提交

answer

#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) ((int)((x).size()))
#define int ll
#define N 500005
using namespace std;
int n,m;
struct node
{
    int t,c,w;
};
int dis[N];
vector<node>E[N];
vector<pa>G[N];
map<int,int>val[N],Mp[N];
void BellaKira()
{
    cin>>n>>m;
    for (int i=1;i<=m;i++)
    {
        int x,y,c,p;
        cin>>x>>y>>c>>p;
        E[x].push_back((node){y,c,p});
        E[y].push_back((node){x,c,p});
        val[x][c]+=p;
        val[y][c]+=p;
    }
    int nn=n;
    for (int i=1;i<=n;i++)
        for (auto u:E[i])
        {
            G[i].push_back(mp(u.t,min(u.w,val[i][u.c]-u.w)));
            if (!Mp[u.t].count(u.c))
            {
                Mp[u.t][u.c]=++nn;
            }
            if (!Mp[i].count(u.c))
            {
                Mp[i][u.c]=++nn;
            }
            G[Mp[i][u.c]].push_back(mp(u.t,min(u.w,val[i][u.c]-u.w)));
            G[i].push_back(mp(Mp[u.t][u.c],0));
        }
    priority_queue<pa>q;
    for (int i=1;i<=nn;i++)
        dis[i]=inf;
    dis[1]=0;
    q.push(mp(0,1));
    while (!q.empty())
    {
        int u=q.top().se;
        int w=-q.top().fi;q.pop();
        if (w!=dis[u]) continue;
        for (auto [v,va]:G[u])
            if (dis[v]>dis[u]+va)
            {
                dis[v]=dis[u]+va;
                q.push(mp(-dis[v],v));
            }
    }
    if (dis[n]==inf) cout<<"-1\n";
    else cout<<dis[n]<<'\n';




}
signed main()
{
    IOS;
    cin.tie(0);
    int T=1;
    while (T--)
    {
        BellaKira();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 34
Accepted
time: 4ms
memory: 73828kb

input:

2 1
1 2 1 10

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 4ms
memory: 73828kb

input:

8 1
5 6 1 7

output:

-1

result:

ok single line: '-1'

Test #3:

score: 0
Accepted
time: 4ms
memory: 73840kb

input:

8 19
4 8 15 5
7 8 15 6
1 4 15 6
3 4 2 10
2 7 15 10
5 6 2 10
1 7 2 3
4 5 15 7
1 6 15 6
2 5 2 6
1 8 15 2
1 2 15 9
5 7 2 5
3 8 2 5
4 7 2 6
6 7 15 8
3 7 15 6
2 8 2 1
5 8 15 6

output:

2

result:

ok single line: '2'

Test #4:

score: 0
Accepted
time: 7ms
memory: 73752kb

input:

4 6
1 2 1 7
3 4 1 10
2 3 2 5
2 4 1 4
1 4 6 2
1 3 1 2

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 8ms
memory: 73840kb

input:

64 106
7 46 100 641441921
4 22 92 909042053
27 46 100 185644091
52 54 100 333473988
21 41 69 747879553
23 45 24 121784836
16 23 69 538978180
15 42 92 403583091
49 60 69 112127397
44 48 21 733685727
18 40 92 287239281
3 30 48 498139743
21 25 24 281665265
13 24 69 315527284
12 35 21 100990101
33 56 10...

output:

-1

result:

ok single line: '-1'

Test #6:

score: -34
Wrong Answer
time: 7ms
memory: 73816kb

input:

10 45
6 7 29 19322896
6 8 29 826842878
5 9 29 229755065
1 6 29 49301462
4 10 29 356862039
3 7 29 377906409
8 10 29 877820670
4 8 29 150486169
1 10 29 291057766
1 5 29 982043864
1 3 29 126557279
5 6 29 721959799
3 10 29 636909401
1 7 29 772752473
5 8 29 523364181
7 9 29 250673970
2 6 29 417264209
2 4...

output:

11555201

result:

wrong answer 1st lines differ - expected: '255671682', found: '11555201'

Subtask #2:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 106ms
memory: 99288kb

input:

25437 78923
921 9998 30945 1
5452 13736 24464 1
11746 24238 24464 1
10875 12958 24464 1
12267 20617 30945 1
3738 16549 35589 1
16223 16940 35589 1
1303 23059 24464 1
12424 21853 24464 1
11198 20674 35589 1
15645 19099 30945 1
8860 9441 24464 1
3609 15160 35589 1
22638 23472 24464 1
766 8991 35589 1
...

output:

4

result:

wrong answer 1st lines differ - expected: '5', found: '4'

Subtask #3:

score: 0
Skipped

Dependency #1:

0%