#include<bits/stdc++.h>
#include "garden.h"
#include "gardenlib.h"
using namespace std;
const int N = 1010;
vector <array <int, 2>> g[N];
void count_routes(int n, int m, int P, int r[][2], int Q, int G[]){
for(int i = 0;i < m;i++){
g[r[i][0]].push_back({i, r[i][1]});
g[r[i][1]].push_back({i, r[i][0]});
}
for(int i = 0;i < n;i++){
sort(g[i].begin(), g[i].end());
}
for(int i =0;i < Q;i++){
int res = 0;
for(int j = 0;j < n;j++){
int v = j, peso = -1;
int k = G[i];
while(k > 0){
if(g[v].empty())k--;
else{
if(g[v][0][0] != peso){
peso = g[v][0][0];
v = g[v][0][1];
}
else{
if(g[v].size() == 1) v = g[v][0][1];
else{
peso = g[v][1][0];
v = g[v][1][1];
}
}
k--;
}
}
if(v == P) res++;
}
answer(res);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
2 ms |
336 KB |
Output is correct |
9 |
Correct |
4 ms |
592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
2 ms |
336 KB |
Output is correct |
9 |
Correct |
4 ms |
592 KB |
Output is correct |
10 |
Correct |
5 ms |
336 KB |
Output is correct |
11 |
Runtime error |
7 ms |
4944 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
2 ms |
336 KB |
Output is correct |
9 |
Correct |
4 ms |
592 KB |
Output is correct |
10 |
Correct |
5 ms |
336 KB |
Output is correct |
11 |
Runtime error |
7 ms |
4944 KB |
Execution killed with signal 11 |
12 |
Halted |
0 ms |
0 KB |
- |