Submission #484195

# Submission time Handle Problem Language Result Execution time Memory
484195 2021-11-02T11:13:39 Z PoPularPlusPlus Tropical Garden (IOI11_garden) C++17
49 / 100
5000 ms 1872 KB
#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long 
#define pb(e) push_back(e)
#define sv(a) sort(a.begin(),a.end())
#define sa(a,n) sort(a,a+n)
#define mp(a,b) make_pair(a,b)
#define vf first
#define vs second
#define ar array
#define all(x) x.begin(),x.end()
const int inf = 0x3f3f3f3f;
const int mod = 1000000007; 
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
bool remender(ll a , ll b){return a%b;}

const int N = 1002;;
int p;
int best[N][2];
int k;

int dfs(int node , int cnt , int pre){
	if(cnt == k){
		if(p == node)return 1;
		return 0;
	}
	int next;
	if(pre == 0){
		next = best[node][0];
	}
	else next = best[node][1];
	if(best[next][0] == node)return dfs(best[node][pre] , cnt + 1 , 1);
	return dfs(best[node][pre] , cnt + 1 , 0);
}

void count_routes(int n, int m, int p1, int r[][2], int q, int g[]){
	p = p1;
	k = g[0];
	vector<int> lol[n + 5];
	for(int i = 0; i < m; i++){
		lol[r[i][0]].pb(r[i][1]);
		lol[r[i][1]].pb(r[i][0]);
	}
	for(int i = 0; i < n; i++){
		best[i][0] = lol[i][0];
		if(lol[i].size() > 1)best[i][1] = lol[i][1];
		else best[i][1] = best[i][0];
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		ans += dfs(i , 0 , 0);
	}
	answer(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 3 ms 204 KB Output is correct
11 Execution timed out 5078 ms 1872 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 3 ms 204 KB Output is correct
11 Execution timed out 5078 ms 1872 KB Time limit exceeded
12 Halted 0 ms 0 KB -