# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
423551 | 2021-06-11T09:21:25 Z | Amylopectin | Hotspot (NOI17_hotspot) | C++14 | 313 ms | 1320 KB |
#include <iostream> #include <stdio.h> #include <vector> #include <queue> using namespace std; const int mxn = 10010,mxi = 1e9 + 10; queue <int> qu; vector <int> pa[mxn] = {}; int di[mxn] = {},u[mxn] = {}; double psu[mxn] = {},npa[mxn] = {},rdi[mxn] = {}; int main() { int i,j,n,m,f,t,cdi,fdi,fn,cn,q,k,stn,enn,su,cou; double cma,df,dt; scanf("%d %d",&n,&m); for(i=0; i<m; i++) { scanf("%d %d",&f,&t); pa[f].push_back(t); pa[t].push_back(f); } scanf("%d",&q); for(i=0; i<q; i++) { scanf("%d %d",&stn,&enn); qu.push(stn); for(j=0; j<n; j++) { di[j] = mxi; npa[j] = 0; rdi[j] = 0; } npa[stn] = 1; di[stn] = 0; while(!qu.empty()) { cn = qu.front(); if(cn == enn) { break; } qu.pop(); for(j=0; j<pa[cn].size(); j++) { fn = pa[cn][j]; if(di[fn] < di[cn]+1) { continue; } if(npa[fn] == 0) { npa[fn] += npa[cn]; di[fn] = di[cn] + 1; qu.push(fn); } else { npa[fn] += npa[cn]; } } } while(!qu.empty()) { qu.pop(); } qu.push(enn); dt = npa[enn]; rdi[enn] = npa[enn]; while(!qu.empty()) { cn = qu.front(); df = rdi[cn]; psu[cn] += df / dt; // if(cn == enn) // { // break; // } qu.pop(); // cu = 0; for(j=0; j<pa[cn].size(); j++) { fn = pa[cn][j]; // if(di[fn] + 1 == di[cn] && u[fn] == i+1) // { // // } if(di[fn] + 1 == di[cn]) { rdi[fn] += (npa[fn] / npa[cn]) * rdi[cn]; } if(di[fn] + 1 == di[cn] && u[fn] != i+1) { u[fn] = i+1; qu.push(fn); } // if(di[fn] == di[cn] + 1) // { // if(u[fn] == i+1) // { // cou ++; // } // } // if(di[fn] < di[cn]+1) // { // continue; // } // if(npa[fn] == 0) // { // npa[fn] += npa[cn]; // di[fn] = di[cn] + 1; // qu.push(fn); // } // else // { // npa[fn] += npa[cn]; // } } // npa[fn] *= cou; // df = npa[fn]; // psu[cn] += df / dt; } } cma = -1; cn = -1; for(i=0; i<n; i++) { if(psu[i] > cma) { cn = i; cma = psu[i]; } } printf("%d\n",cn); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 588 KB | Output is correct |
3 | Correct | 1 ms | 544 KB | Output is correct |
4 | Correct | 1 ms | 460 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 460 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 588 KB | Output is correct |
3 | Correct | 1 ms | 544 KB | Output is correct |
4 | Correct | 1 ms | 460 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 460 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 536 KB | Output is correct |
9 | Correct | 1 ms | 588 KB | Output is correct |
10 | Correct | 1 ms | 588 KB | Output is correct |
11 | Correct | 1 ms | 460 KB | Output is correct |
12 | Correct | 1 ms | 460 KB | Output is correct |
13 | Correct | 1 ms | 460 KB | Output is correct |
14 | Correct | 1 ms | 588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 588 KB | Output is correct |
3 | Correct | 1 ms | 544 KB | Output is correct |
4 | Correct | 1 ms | 460 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 460 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 460 KB | Output is correct |
9 | Correct | 1 ms | 588 KB | Output is correct |
10 | Correct | 2 ms | 588 KB | Output is correct |
11 | Correct | 2 ms | 588 KB | Output is correct |
12 | Correct | 1 ms | 460 KB | Output is correct |
13 | Correct | 1 ms | 460 KB | Output is correct |
14 | Correct | 2 ms | 460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 588 KB | Output is correct |
3 | Correct | 1 ms | 544 KB | Output is correct |
4 | Correct | 1 ms | 460 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 460 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 536 KB | Output is correct |
9 | Correct | 1 ms | 588 KB | Output is correct |
10 | Correct | 1 ms | 588 KB | Output is correct |
11 | Correct | 1 ms | 460 KB | Output is correct |
12 | Correct | 1 ms | 460 KB | Output is correct |
13 | Correct | 1 ms | 460 KB | Output is correct |
14 | Correct | 1 ms | 588 KB | Output is correct |
15 | Correct | 1 ms | 460 KB | Output is correct |
16 | Correct | 1 ms | 588 KB | Output is correct |
17 | Correct | 2 ms | 588 KB | Output is correct |
18 | Correct | 2 ms | 588 KB | Output is correct |
19 | Correct | 1 ms | 460 KB | Output is correct |
20 | Correct | 1 ms | 460 KB | Output is correct |
21 | Correct | 2 ms | 460 KB | Output is correct |
22 | Correct | 1 ms | 532 KB | Output is correct |
23 | Correct | 1 ms | 460 KB | Output is correct |
24 | Correct | 2 ms | 588 KB | Output is correct |
25 | Correct | 3 ms | 588 KB | Output is correct |
26 | Correct | 2 ms | 540 KB | Output is correct |
27 | Correct | 1 ms | 460 KB | Output is correct |
28 | Correct | 2 ms | 508 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 588 KB | Output is correct |
3 | Correct | 1 ms | 544 KB | Output is correct |
4 | Correct | 1 ms | 460 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 460 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 536 KB | Output is correct |
9 | Correct | 1 ms | 588 KB | Output is correct |
10 | Correct | 1 ms | 588 KB | Output is correct |
11 | Correct | 1 ms | 460 KB | Output is correct |
12 | Correct | 1 ms | 460 KB | Output is correct |
13 | Correct | 1 ms | 460 KB | Output is correct |
14 | Correct | 1 ms | 588 KB | Output is correct |
15 | Correct | 3 ms | 588 KB | Output is correct |
16 | Correct | 2 ms | 588 KB | Output is correct |
17 | Correct | 3 ms | 716 KB | Output is correct |
18 | Correct | 2 ms | 588 KB | Output is correct |
19 | Correct | 3 ms | 672 KB | Output is correct |
20 | Correct | 3 ms | 588 KB | Output is correct |
21 | Correct | 1 ms | 588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 588 KB | Output is correct |
3 | Correct | 1 ms | 544 KB | Output is correct |
4 | Correct | 1 ms | 460 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 460 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 536 KB | Output is correct |
9 | Correct | 1 ms | 588 KB | Output is correct |
10 | Correct | 1 ms | 588 KB | Output is correct |
11 | Correct | 1 ms | 460 KB | Output is correct |
12 | Correct | 1 ms | 460 KB | Output is correct |
13 | Correct | 1 ms | 460 KB | Output is correct |
14 | Correct | 1 ms | 588 KB | Output is correct |
15 | Correct | 1 ms | 460 KB | Output is correct |
16 | Correct | 1 ms | 588 KB | Output is correct |
17 | Correct | 2 ms | 588 KB | Output is correct |
18 | Correct | 2 ms | 588 KB | Output is correct |
19 | Correct | 1 ms | 460 KB | Output is correct |
20 | Correct | 1 ms | 460 KB | Output is correct |
21 | Correct | 2 ms | 460 KB | Output is correct |
22 | Correct | 1 ms | 532 KB | Output is correct |
23 | Correct | 1 ms | 460 KB | Output is correct |
24 | Correct | 2 ms | 588 KB | Output is correct |
25 | Correct | 3 ms | 588 KB | Output is correct |
26 | Correct | 2 ms | 540 KB | Output is correct |
27 | Correct | 1 ms | 460 KB | Output is correct |
28 | Correct | 2 ms | 508 KB | Output is correct |
29 | Correct | 3 ms | 588 KB | Output is correct |
30 | Correct | 2 ms | 588 KB | Output is correct |
31 | Correct | 3 ms | 716 KB | Output is correct |
32 | Correct | 2 ms | 588 KB | Output is correct |
33 | Correct | 3 ms | 672 KB | Output is correct |
34 | Correct | 3 ms | 588 KB | Output is correct |
35 | Correct | 1 ms | 588 KB | Output is correct |
36 | Correct | 30 ms | 672 KB | Output is correct |
37 | Correct | 67 ms | 848 KB | Output is correct |
38 | Correct | 313 ms | 1248 KB | Output is correct |
39 | Correct | 231 ms | 1260 KB | Output is correct |
40 | Correct | 31 ms | 844 KB | Output is correct |
41 | Correct | 198 ms | 1320 KB | Output is correct |
42 | Correct | 232 ms | 1296 KB | Output is correct |
43 | Correct | 18 ms | 780 KB | Output is correct |
44 | Correct | 16 ms | 716 KB | Output is correct |