# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
898712 | 2024-01-05T03:55:21 Z | MuhammadSaram | Tropical Garden (IOI11_garden) | C++17 | 418 ms | 262144 KB |
#include <bits/stdc++.h> #include "gardenlib.h" using namespace std; void count_routes(int n, int m, int p, int G[][2], int q, int K[]) { vector<pair<int,int>> nei[n]; vector<int> Ne[n]; map<int,int[2]> dp[n][30]; for (int i=0;i<m;i++) { nei[G[i][0]].push_back({i,G[i][1]}); nei[G[i][1]].push_back({i,G[i][0]}); } for (int i=0;i<n;i++) { if (nei[i].size()>1) for (int j=0;j<nei[i].size();j++) { dp[i][0][nei[i][j].first][0]=nei[i][!j].first; dp[i][0][nei[i][j].first][1]=nei[i][!j].second; } else { dp[i][0][nei[i][0].first][0]=nei[i][0].first; dp[i][0][nei[i][0].first][1]=nei[i][0].second; } dp[i][0][m][0]=nei[i][0].first; dp[i][0][m][1]=nei[i][0].second; } for (int i=0;i<n;i++) nei[i].clear(); for (int i=0;i<m;i++) { Ne[G[i][0]].push_back(i); Ne[G[i][1]].push_back(i); } for (int k=1;k<30;k++) for (int i=0;i<n;i++) { for (int j=0;j<Ne[i].size();j++) { dp[i][k][Ne[i][j]][0]=dp[dp[i][k-1][Ne[i][j]][1]][k-1][dp[i][k-1][Ne[i][j]][0]][0]; dp[i][k][Ne[i][j]][1]=dp[dp[i][k-1][Ne[i][j]][1]][k-1][dp[i][k-1][Ne[i][j]][0]][1]; } dp[i][k][m][0]=dp[dp[i][k-1][m][1]][k-1][dp[i][k-1][m][0]][0]; dp[i][k][m][1]=dp[dp[i][k-1][m][1]][k-1][dp[i][k-1][m][0]][1]; } for (int j=0;j<q;j++) { int ans=0,qu=K[j]; for (int i=0;i<n;i++) { int u=i,ed=m; for (int k=29;k>=0;k--) if ((1<<k)&qu) { int x=dp[u][k][ed][1]; ed=dp[u][k][ed][0]; u=x; } if (u==p) ans++; } answer(ans); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 5980 KB | Output is correct |
2 | Correct | 9 ms | 7260 KB | Output is correct |
3 | Correct | 12 ms | 7852 KB | Output is correct |
4 | Correct | 1 ms | 600 KB | Output is correct |
5 | Correct | 1 ms | 600 KB | Output is correct |
6 | Correct | 24 ms | 11356 KB | Output is correct |
7 | Correct | 2 ms | 1116 KB | Output is correct |
8 | Correct | 11 ms | 7480 KB | Output is correct |
9 | Correct | 90 ms | 34160 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 5980 KB | Output is correct |
2 | Correct | 9 ms | 7260 KB | Output is correct |
3 | Correct | 12 ms | 7852 KB | Output is correct |
4 | Correct | 1 ms | 600 KB | Output is correct |
5 | Correct | 1 ms | 600 KB | Output is correct |
6 | Correct | 24 ms | 11356 KB | Output is correct |
7 | Correct | 2 ms | 1116 KB | Output is correct |
8 | Correct | 11 ms | 7480 KB | Output is correct |
9 | Correct | 90 ms | 34160 KB | Output is correct |
10 | Correct | 1 ms | 1116 KB | Output is correct |
11 | Correct | 366 ms | 163924 KB | Output is correct |
12 | Runtime error | 418 ms | 262144 KB | Execution killed with signal 9 |
13 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 5980 KB | Output is correct |
2 | Correct | 9 ms | 7260 KB | Output is correct |
3 | Correct | 12 ms | 7852 KB | Output is correct |
4 | Correct | 1 ms | 600 KB | Output is correct |
5 | Correct | 1 ms | 600 KB | Output is correct |
6 | Correct | 24 ms | 11356 KB | Output is correct |
7 | Correct | 2 ms | 1116 KB | Output is correct |
8 | Correct | 11 ms | 7480 KB | Output is correct |
9 | Correct | 90 ms | 34160 KB | Output is correct |
10 | Correct | 1 ms | 1116 KB | Output is correct |
11 | Correct | 366 ms | 163924 KB | Output is correct |
12 | Runtime error | 418 ms | 262144 KB | Execution killed with signal 9 |
13 | Halted | 0 ms | 0 KB | - |