Submission #517006

# Submission time Handle Problem Language Result Execution time Memory
517006 2022-01-22T11:06:20 Z sudheerays123 Walking (NOI12_walking) C++
0 / 25
3 ms 976 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);
vi dist(N);
ll maxcycle;

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

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

	visited[s] = true;
	dist[s] = d;

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

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,1,n){
			if(t[i] < t[j] && (((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 1 ms 424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 464 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 976 KB Output isn't correct
2 Halted 0 ms 0 KB -