QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#646289#8517. Interesting PathswangxiaoruiWA 15ms58516kbC++141014b2024-10-16 22:05:112024-10-16 22:05:11

Judging History

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

  • [2024-10-16 22:05:11]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:58516kb
  • [2024-10-16 22:05:11]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define F(x,y,z) for(int x=(y);x<=(z);x++)
using namespace std;
const int N=1000010;
int n,m;
int cntn,cntm;
struct Edge{
    int to,id;
};
vector <Edge> e1[N],e2[N]; 
int vis1[N],vis2[N];
int vie1[N],vie2[N];
int main(){ 
    cin>>n>>m;
    int u,v;
    Edge t;
    for(int i=1;i<=m;i++){
        cin>>u>>v;
        t.to=v;t.id=i;
        e1[u].push_back(t);
        t.to=u;
        e2[v].push_back(t);
    }
    vis1[1]=1;
    for(int x=1;x<=n;x++)
        for(auto y:e1[x]){
            vis1[y.to]=vis1[y.to] | vis1[x];
            vie1[y.id]=vie1[y.id] | vis1[x];
        }
    vis2[n]=1;
    for(int x=n;x>=1;x--)
        for(auto y:e2[x]){
            vis2[y.to]=vis2[y.to] | vis2[x];
            vie2[y.id]=vie2[y.id] | vis2[x];
        }
    if(!vis2[1]){
        cout<<0<<endl;
        return 0;
    }
    for(int i=1;i<=n;i++) if(vis1[i] && vis2[i]) cntn++;
    for(int i=1;i<=m;i++) if(vie1[i] && vie1[i]) cntm++;
    cout<<cntm-cntn+2<<endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 58516kb

input:

5 7
1 3
3 5
1 2
2 3
3 4
4 5
2 4

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

5 3
1 3
2 3
2 5

output:

0

result:

ok 1 number(s): "0"

Test #3:

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

input:

2 0

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 3ms
memory: 56700kb

input:

2 1
1 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 3ms
memory: 57496kb

input:

10 20
2 8
5 8
4 8
3 10
3 7
2 7
2 5
1 7
6 9
6 10
2 4
5 9
2 10
3 9
7 8
4 10
3 6
2 3
5 7
6 8

output:

0

result:

ok 1 number(s): "0"

Test #6:

score: 0
Accepted
time: 15ms
memory: 57516kb

input:

10 30
8 9
1 5
3 6
4 6
4 7
6 9
3 5
5 6
3 8
1 4
3 4
7 8
2 4
4 5
1 8
6 10
2 10
9 10
1 2
8 10
2 7
2 8
2 5
7 9
2 6
4 8
1 7
1 6
7 10
4 9

output:

19

result:

ok 1 number(s): "19"

Test #7:

score: -100
Wrong Answer
time: 3ms
memory: 58160kb

input:

20 57
6 20
5 9
8 11
6 17
5 18
14 16
6 18
8 18
1 3
17 20
2 16
4 19
2 15
7 17
17 19
8 16
11 15
13 16
5 20
4 14
5 16
7 12
10 12
3 12
8 13
1 5
6 11
13 17
11 16
2 6
4 5
14 15
3 14
9 13
8 10
18 20
15 17
6 12
5 17
2 10
8 17
15 16
15 20
5 19
10 15
1 2
4 20
4 18
3 16
2 12
8 19
10 19
2 11
12 17
12 20
5 7
1 15

output:

31

result:

wrong answer 1st numbers differ - expected: '21', found: '31'