# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
164887 | DavidDamian | Tropical Garden (IOI11_garden) | C++11 | 5 ms | 1116 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "garden.h"
#include "gardenlib.h"
#include<bits/stdc++.h>
using namespace std;
void answer(int x);
struct edge
{
int from,to;
int w;
};
bool operator<(const edge e1,const edge e2)
{
if(e1.w>e2.w) return true;
else return false;
}
vector <edge> adjList[1005];
int routes[1005][105];
void make_route(int u)
{
int last_taken=-1;
int v=u;
for(int i=0;i<101;i++){
routes[u][i]=v;
if(adjList[v][0].w!=last_taken || adjList[v].size()==1){
last_taken=adjList[v][0].w;
v=adjList[v][0].to;
}
else{
last_taken=adjList[v][1].w;
v=adjList[v][1].to;
}
}
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
if(N>1000) return;
for(int i=0;i<M;i++){
int u=R[i][0];
int v=R[i][1];
edge e={u,v,M-i};
adjList[u].push_back(e);
swap(e.from,e.to);
adjList[v].push_back(e);
}
for(int u=0;u<N;u++){
int x=adjList[u].size();
sort(adjList[u].begin(),adjList[u].end());
}
for(int u=0;u<N;u++){
make_route(u);
}
int sum;
for(int i=0; i<Q; i++){
sum=0;
for(int u=0;u<N;u++){
if(routes[ u ][ G[i] ]==P) sum++;
}
answer(sum);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |