QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#616722#8517. Interesting PathsbadmintonWA 6ms28284kbC++141.7kb2024-10-06 10:43:412024-10-06 10:43:41

Judging History

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

  • [2024-10-06 10:43:41]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:28284kb
  • [2024-10-06 10:43:41]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
typedef pair <int,int> pii;
typedef pair <int,pii> piii;

#define forr(_a,_b,_c) for(int _a = (_b); _a <= int (_c); ++_a)
#define ford(_a,_b,_c) for(int _a = (_b) + 1; _a --> int (_c);)
#define forf(_a,_b,_c) for(int _a = (_b); _a < int (_c); ++_a)
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define mask(i) (1LL << (i))
#define bit(x, i) (((x) >> (i)) & 1)
#define bp __builtin_popcountll
#define file "test"

template<class X, class Y>
    bool minz(X &x, const Y &y) {
        if (x > y) {
            x = y;
            return true;
        } return false;
    }
template<class X, class Y>
    bool maxz(X &x, const Y &y) {
        if (x < y) {
            x = y;
            return true;
        } return false;
    }

const int N = 5e5 + 5;
const ll oo = (ll) 1e16;
const ll mod = 1e9 + 7; // 998244353;

int n, m, u, v, res, f[N];
vector <int> a[N], ra[N];


void dfs2 (int u){
    f[u] = 1;
    for (int v : ra[u])
    if (!f[v])
        dfs2(v);
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef hqm
        freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
    #endif

    cin >> n >> m;

    forr (i, 1, m){
        cin >> u >> v;
        a[u].pb(v);
        ra[v].pb(u);
    }

    dfs2(n);
    
    forr (i, 1, n){
        int cnt = 0;
        
        for (int v : a[i]){
            cnt += f[v];    
        }
        
        if (cnt) res += cnt - (i != 1);
    }

    cout << res << "\n";

    return 0;
}
/*



*/


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 6ms
memory: 28284kb

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: 0ms
memory: 27204kb

input:

5 3
1 3
2 3
2 5

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 0ms
memory: 28272kb

input:

2 0

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 5ms
memory: 28164kb

input:

2 1
1 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

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:

3

result:

wrong answer 1st numbers differ - expected: '0', found: '3'