QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#100445#4992. Enigmatic EnumerationjoesmittyWA 1578ms3792kbC++203.7kb2023-04-26 10:33:092023-04-26 10:33:13

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-26 10:33:13]
  • 评测
  • 测评结果:WA
  • 用时:1578ms
  • 内存:3792kb
  • [2023-04-26 10:33:09]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef vector<int> vi;
typedef vector< vector <int> > vvi;
typedef pair<int, int> pii;
typedef pair < pair < int, int >, int > piii;
typedef pair < pair <int, int > , pair <int, int> > piiii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
 
#define FOR(i,a,b) for(int i = a; i < b; i ++)
#define RFOR(i,a,b) for(int i = a-1; i >= b; i --)
#define all(a) a.begin(), a.end()
#define endl '\n';
#define sz(x) (int)(x).size()
 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
 
template <typename T>
void pr(vector<T> &v) {
    FOR(i, 0, sz(v)) cout << v[i] << " ";
    cout << endl;
}
template <typename T>
void pr(vector<vector<T> > &v) {
    FOR(i, 0, sz(v)) { pr(v[i]); }
}
template <typename T>
void re(T &x) {
    cin >> x;
}
template <typename T>
void re(vector<T> &a) {
    FOR(i, 0, sz(a)) re(a[i]);
}
template <class Arg, class... Args>
void re(Arg &first, Args &... rest) {
    re(first);
    re(rest...);
}
template <typename T>
void pr(T x) {
    cout << x << endl;
}
template <class Arg, class... Args>
void pr(const Arg &first, const Args &... rest) {
    cout << first << " ";
    pr(rest...);
    cout << endl;
}
void ps() { cout << endl; }
template<class T, class... Ts>
void ps(const T& t, const Ts&... ts) {
    cout << t; if (sizeof...(ts)) cout << " "; ps(ts...);
}
 
const ll MOD  =  998244353;
#define inf 1e18;
#define INF INT_MAX

long double PI = 4*atan(1);
long double eps = 1e-12;


vi adj[3010] = {};
vector<pii> edges;
int n,m; 
vi minlen(3010, 1e8);
vi mincnt(3010, 0);

ll minv = 1e9;
ll minc = 0;

void bfs(int o, int b, vi &d, vi &cnt) {
    queue<pii> q;
    d[o] = 0;
    cnt[o] = 1;
    q.push({o,0});

    while(!q.empty()) {
        pii c = q.front(); q.pop();
        int u = c.ff;
        int dd = c.ss;
        for(auto v : adj[u]) {
            if(u == o && v == b) continue;
            if(d[v] == 1e8) {
                d[v] = dd + 1;
                cnt[v] = cnt[o];
                q.push({v, dd+1});
            } else if(d[v] == dd + 1) {
                cnt[v] += cnt[o];
            }
        }
    }
}

void rem(pii e) {
    int o1 = e.ff;
    int o2 = e.ss;

    vi dist1(n, 1e8);
    vi cnt1(n, 0);
    bfs(o1, o2, dist1, cnt1);
    vi cnt2(n,0);
    vi dist2(n, 1e8);
    bfs(o2, o1, dist2, cnt2);

    for(int i = 0; i < n; i++) {
        if(i == o1 || i == o2) continue;
        int d = dist1[i] + dist2[i];
        if(d < 1e8) {
            if(d < minv) {
                minv = d;
                minc = cnt1[i] * cnt2[i];
            } else if(d == minv) {
                minc += cnt1[i] * cnt2[i];
            }
        }
    }
}

int main() {
    auto start = chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0);cin.tie(0);
    // ofstream cout("disrupt.out");
    // ifstream cin("disrupt.in");
    #ifdef DEBUG
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif  

    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int u,v;
        cin >> u >> v; u--; v--;
        adj[u].pb(v);
        adj[v].pb(u);
        edges.pb({u,v});
    }

    for(auto e : edges) {
        rem(e);
    }

    cout << minc / ((minv - 1) * (minv + 1)) << endl;


    
    // auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::microseconds>(stop - start);
    // cout << duration.count() << endl;
    //cin.close();
    //cout.close();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3512kb

input:

4 4
1 2
2 3
3 4
4 1

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3508kb

input:

5 10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5

output:

10

result:

ok single line: '10'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3480kb

input:

6 6
1 2
2 3
3 1
4 5
5 6
6 4

output:

2

result:

ok single line: '2'

Test #4:

score: 0
Accepted
time: 269ms
memory: 3676kb

input:

110 5995
109 20
100 23
99 65
106 40
105 62
89 67
57 9
83 38
38 20
28 11
39 28
32 20
108 90
96 50
97 51
80 40
64 48
101 27
84 27
43 35
103 79
70 32
29 28
109 2
43 16
110 94
101 71
84 67
23 19
33 17
107 79
90 33
83 64
57 39
105 46
47 1
80 79
93 67
78 53
34 20
105 15
77 66
65 63
102 57
76 59
47 40
95 4...

output:

215820

result:

ok single line: '215820'

Test #5:

score: 0
Accepted
time: 281ms
memory: 3720kb

input:

110 5985
50 38
109 70
110 85
50 23
71 51
52 2
43 32
74 28
98 13
103 94
108 54
41 12
55 12
51 10
44 2
56 35
8 6
27 2
72 19
92 65
64 42
31 20
110 67
74 46
93 57
59 5
63 50
33 31
98 42
75 59
103 87
81 79
99 20
100 84
89 87
87 78
67 56
85 74
14 7
103 16
42 41
29 13
68 26
110 7
91 63
86 78
86 85
44 42
10...

output:

214742

result:

ok single line: '214742'

Test #6:

score: 0
Accepted
time: 281ms
memory: 3592kb

input:

154 5929
68 88
68 153
67 84
64 134
51 120
38 102
68 82
54 105
50 135
2 103
75 140
17 150
40 127
19 152
8 98
70 144
76 134
7 94
12 109
33 152
14 124
7 96
30 140
9 118
71 110
12 121
17 123
3 112
63 96
35 153
43 122
36 82
24 114
21 111
69 88
76 117
41 126
68 151
32 104
39 150
19 133
1 140
14 114
33 145...

output:

8561476

result:

ok single line: '8561476'

Test #7:

score: 0
Accepted
time: 289ms
memory: 3664kb

input:

154 5919
47 107
73 107
15 125
22 151
65 91
54 151
52 100
64 127
77 115
65 80
3 99
50 86
12 139
57 88
48 137
71 148
44 95
31 122
49 139
3 149
43 107
34 85
67 142
75 97
56 146
72 135
72 116
18 94
2 97
63 151
54 145
32 101
62 128
75 89
36 147
41 120
35 142
46 129
65 94
6 141
53 146
21 132
29 98
55 81
2...

output:

8503911

result:

ok single line: '8503911'

Test #8:

score: 0
Accepted
time: 284ms
memory: 3676kb

input:

154 5919
40 117
56 137
52 141
57 118
29 107
18 128
74 111
54 78
73 87
69 134
38 124
50 112
70 99
43 122
72 87
52 134
57 123
43 86
4 79
52 129
68 126
58 127
77 128
25 141
61 127
57 146
7 124
39 83
55 111
62 130
2 83
44 104
2 119
40 105
8 152
36 130
67 100
3 106
9 99
6 118
43 141
40 126
76 109
51 87
1...

output:

8503986

result:

ok single line: '8503986'

Test #9:

score: 0
Accepted
time: 175ms
memory: 3676kb

input:

3000 3000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
5...

output:

1

result:

ok single line: '1'

Test #10:

score: 0
Accepted
time: 98ms
memory: 3676kb

input:

3000 3000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
5...

output:

2

result:

ok single line: '2'

Test #11:

score: 0
Accepted
time: 173ms
memory: 3728kb

input:

2999 2999
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
5...

output:

1

result:

ok single line: '1'

Test #12:

score: 0
Accepted
time: 98ms
memory: 3656kb

input:

2998 2998
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
5...

output:

2

result:

ok single line: '2'

Test #13:

score: 0
Accepted
time: 94ms
memory: 3680kb

input:

2999 2999
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
5...

output:

1

result:

ok single line: '1'

Test #14:

score: 0
Accepted
time: 98ms
memory: 3676kb

input:

2999 2999
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
5...

output:

1

result:

ok single line: '1'

Test #15:

score: 0
Accepted
time: 182ms
memory: 3608kb

input:

2999 2999
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
5...

output:

1

result:

ok single line: '1'

Test #16:

score: 0
Accepted
time: 180ms
memory: 3672kb

input:

3000 3000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
5...

output:

2

result:

ok single line: '2'

Test #17:

score: 0
Accepted
time: 176ms
memory: 3656kb

input:

2998 2998
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
5...

output:

2

result:

ok single line: '2'

Test #18:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

3000 3
1 2
2 3
3 1

output:

1

result:

ok single line: '1'

Test #19:

score: 0
Accepted
time: 357ms
memory: 3644kb

input:

113 6000
107 75
95 35
65 37
103 96
47 44
87 85
93 13
63 46
66 65
99 93
107 37
78 54
99 94
99 80
106 6
50 33
49 35
66 20
80 64
61 52
48 9
81 41
42 4
108 22
104 25
108 52
112 11
87 61
16 8
75 50
14 2
104 68
81 7
57 33
58 31
73 65
78 42
107 104
106 96
76 27
66 6
76 56
95 13
105 6
92 36
81 73
95 8
26 3
...

output:

199594

result:

ok single line: '199594'

Test #20:

score: 0
Accepted
time: 408ms
memory: 3696kb

input:

241 6000
92 87
180 129
111 76
230 169
143 20
105 74
194 88
62 12
118 85
115 95
236 117
53 49
175 16
228 7
128 27
174 173
177 85
54 24
191 44
212 141
208 164
7 2
63 16
91 25
179 45
190 162
186 41
131 44
209 58
77 71
65 6
164 6
128 52
145 5
97 44
195 155
144 37
185 126
232 66
120 104
160 70
127 118
20...

output:

20438

result:

ok single line: '20438'

Test #21:

score: 0
Accepted
time: 783ms
memory: 3680kb

input:

629 6000
587 450
474 389
622 552
155 92
426 403
329 73
473 381
136 131
225 108
535 199
568 488
436 220
404 269
606 190
465 344
37 25
342 239
541 364
404 150
409 176
471 433
455 74
408 152
371 259
430 104
548 273
397 308
447 317
343 41
105 66
287 78
509 28
171 164
363 238
506 168
550 102
547 513
606 ...

output:

1160

result:

ok single line: '1160'

Test #22:

score: 0
Accepted
time: 968ms
memory: 3744kb

input:

1100 6000
916 280
258 17
974 279
964 233
567 262
856 688
422 314
945 355
1057 935
651 410
894 605
714 145
674 506
451 56
786 603
530 14
306 150
1084 15
791 682
827 747
933 208
712 31
491 263
449 374
784 683
655 396
683 89
743 581
785 688
1044 322
927 44
711 542
889 288
373 295
654 392
1003 140
754 6...

output:

211

result:

ok single line: '211'

Test #23:

score: 0
Accepted
time: 1424ms
memory: 3764kb

input:

2420 6000
936 243
1657 936
2030 1517
1601 266
1730 189
1850 843
1734 1127
501 476
962 952
1894 115
2066 862
1499 1266
2404 1837
2221 1403
1719 846
985 429
1576 43
2292 406
1603 1527
2172 1283
2042 1306
1509 1472
1931 1198
1875 586
1905 661
2236 1112
971 338
1997 1296
1393 1225
135 26
2129 432
1545 9...

output:

14

result:

ok single line: '14'

Test #24:

score: 0
Accepted
time: 1578ms
memory: 3792kb

input:

3000 6000
1000 830
2457 395
2683 287
982 722
2746 1289
2223 172
1931 979
2429 1200
2536 581
2673 1998
1926 1453
909 31
1342 1040
2579 1502
2569 534
2684 1771
1730 456
2119 1774
2393 130
1389 1172
2458 1427
2937 452
1612 1497
2601 1561
2689 2280
1912 1271
2214 1245
1676 1486
2696 2066
2319 105
2029 1...

output:

13

result:

ok single line: '13'

Test #25:

score: 0
Accepted
time: 1156ms
memory: 3664kb

input:

3000 5000
2786 2564
2999 2133
625 377
2806 208
429 222
2846 938
1314 1076
1102 601
716 231
786 289
1521 268
1358 117
2878 1045
1247 803
1488 19
1959 569
2912 1590
2137 1535
1673 1671
2407 388
1941 27
1776 374
1612 280
2193 1776
1757 794
2608 1785
1911 570
2215 1914
1335 921
1157 69
2183 319
1951 351...

output:

11

result:

ok single line: '11'

Test #26:

score: 0
Accepted
time: 386ms
memory: 3692kb

input:

3000 3000
2190 243
2598 2062
1346 527
2880 2843
2735 1419
919 395
2951 1434
1282 1230
1799 358
1904 1533
2969 709
2146 366
2515 829
2494 814
1704 990
2295 2218
985 35
545 45
2589 271
841 42
2918 2845
503 488
2073 1928
1744 772
2571 2457
1740 826
2287 1149
2511 1969
2830 744
840 104
2476 1087
823 626...

output:

2

result:

ok single line: '2'

Test #27:

score: -100
Wrong Answer
time: 34ms
memory: 3540kb

input:

300 1000
260 208
83 78
299 222
30 127
166 247
72 2
104 259
123 249
177 113
168 83
224 34
261 135
256 251
271 283
88 100
217 204
137 274
87 213
35 174
80 42
140 232
205 226
193 118
41 87
149 242
299 159
124 137
116 61
108 215
129 200
295 80
45 152
95 183
18 82
300 234
82 253
51 297
237 186
116 135
11...

output:

4232

result:

wrong answer 1st lines differ - expected: '5050', found: '4232'