Submission #517027

# Submission time Handle Problem Language Result Execution time Memory
517027 2022-01-22T11:48:37 Z sudheerays123 Walking (NOI12_walking) C++
0 / 25
4 ms 1740 KB
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define tc ll test;cin >> test;while(test--)
#define vi vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define INF 1e18
#define MOD 1000000007
#define ff first
#define ss second
#define in >>
#define out <<
#define space << " " <<
#define spacef << " "
#define fo(i,a,b) for(ll i = a; i <= b; i++)
#define nextline out "\n"
#define print(x) for(auto i : x ) cout out i spacef
#define mmax(x,i) x = max(x,i)
#define mmin(x,i) x = min(x,i)
#define N 505

vi adj[N];
vector<bool> visited(N,false);
ll maxcycle;
vi dist(N);
stack<ll> path;

void dfs(ll s , ll p , ll d){

	if(visited[s]){
		mmax(maxcycle,d-dist[s]);
		return;
	}

	path.push(s);
	dist[s] = d;
	visited[s] = true;

	for(auto u : adj[s]){
		if(u == p) continue;
		dfs(u,s,d+1);
	}

	path.pop();
}

int main() {
    
    fast;

	ll l,n;
	cin in l in n;

	vi t(n+5);
	vi v(n+5);

	fo(i,1,n) cin in t[i] in v[i];

	fo(i,1,n){
		fo(j,i+1,n){
			if((((double)l/(double)v[i]) + t[i]) > (((double)l/(double)v[j]) + t[j])){
				adj[i].pb(j);
				adj[j].pb(i);
			}
		}
	}

	ll ans = 1;

	fo(i,1,n){
		if(!visited[i]){
			maxcycle = -INF;
			dfs(i,-1,0);
			mmax(ans,maxcycle);
		}
	}

	cout out ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1740 KB Output isn't correct
2 Halted 0 ms 0 KB -