# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
411546 | 2021-05-25T13:38:14 Z | A_D | 열대 식물원 (Tropical Garden) (IOI11_garden) | C++14 | 17 ms | 5004 KB |
#include "garden.h" #include "gardenlib.h" #include <bits/stdc++.h> #define ii pair<int,int> #define F first #define S second using namespace std; const int NN=3e3+100; vector<ii> g[NN]; bool dp[NN][NN][3]; int p,n; int ok(int u,int v) { int ret=2; for(int i=0;i<g[u].size();i++){ if(i==2)break; if(g[u][i].S==v){ ret=i; break; } } return ret; } void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) { p=P; n=N; for(int i=0;i<n;i++)g[i].clear(); for(int i=0;i<M;i++){ int u=R[i][0]; int v=R[i][1]; g[u].push_back({i,v}); g[v].push_back({i,u}); } for(int i=0;i<n;i++)sort(g[i].begin(),g[i].end()); int k=G[0]; dp[p][0][2]=1; for(int t=0;t<k;t++){ for(int i=0;i<n;i++){ for(int skip=0;skip<3;skip++){ if(dp[i][t][skip]){ if(skip==1){ int x=g[i][0].S; int q=ok(x,i); if(q<2){ dp[x][t+1][q]=1; } continue; } for(int r=0;r<g[i].size();r++){ if(r==skip&&g[i].size()!=1&&skip!=2)continue; int x=g[i][r].S; int q=ok(x,i); if(q>1)continue; dp[x][t+1][q]=1; } } } } } /* cout<<endl; for(int t=0;t<=k;t++){ for(int i=0;i<n;i++){ for(int skip=0;skip<3;skip++){ cout<<dp[i][t][skip]<<" "; } cout<<endl; } cout<<endl; } cout<<endl; */ int ans=0; for(int i=0;i<n;i++){ ans+=dp[i][k][0]; } answer(ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 844 KB | Output is correct |
2 | Correct | 4 ms | 3148 KB | Output is correct |
3 | Correct | 4 ms | 2508 KB | Output is correct |
4 | Correct | 1 ms | 588 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 3 ms | 908 KB | Output is correct |
7 | Correct | 1 ms | 588 KB | Output is correct |
8 | Correct | 6 ms | 4608 KB | Output is correct |
9 | Correct | 8 ms | 5004 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 844 KB | Output is correct |
2 | Correct | 4 ms | 3148 KB | Output is correct |
3 | Correct | 4 ms | 2508 KB | Output is correct |
4 | Correct | 1 ms | 588 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 3 ms | 908 KB | Output is correct |
7 | Correct | 1 ms | 588 KB | Output is correct |
8 | Correct | 6 ms | 4608 KB | Output is correct |
9 | Correct | 8 ms | 5004 KB | Output is correct |
10 | Incorrect | 17 ms | 1324 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 844 KB | Output is correct |
2 | Correct | 4 ms | 3148 KB | Output is correct |
3 | Correct | 4 ms | 2508 KB | Output is correct |
4 | Correct | 1 ms | 588 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 3 ms | 908 KB | Output is correct |
7 | Correct | 1 ms | 588 KB | Output is correct |
8 | Correct | 6 ms | 4608 KB | Output is correct |
9 | Correct | 8 ms | 5004 KB | Output is correct |
10 | Incorrect | 17 ms | 1324 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |