/*input
*/
/**
Author: Kristopher Paul
Date Created: 11-02-2021
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include<unordered_map>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
//#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset
int ModExp(int x,int y,int m){
int res = 1;
x = x % m;
while (y > 0)
{
if (y & 1)
res = (res*x) % m;
y = y>>1;
x = (x*x) % m;
}
return res;
}
vi adj[1005];
int val[1005];
int dfs(int cv,int p,int c){
FOR(i,0,adj[cv].size()){
if(adj[cv][i] != p){
c = dfs(adj[cv][i],cv,c);
}
}
val[cv] = c;
return c+1;
}
vi label(int n,int k,vi u,vi v){
FOR(i,0,n){
adj[i].clear();
}
FOR(i,0,n-1){
adj[u[i]].pb(v[i]);
adj[v[i]].pb(u[i]);
}
dfs(0,-1,0);
vi ans;
FOR(i,0,n){
ans.pb(val[i]);
}
return ans;
}
int find_next_station(int s,int t,vi c){
if(c.size() == 1){
return c[0];
}
if(c.size() == 2){
if(t <= c[0]){
return c[0];
}else{
return c[1];
}
}
if(t <= c[0]){
return c[0];
}else if(t <= c[1]){
return c[1];
}else{
return c[2];
}
}
Compilation message
stations.cpp: In function 'int dfs(int, int, int)':
stations.cpp:22:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | #define FOR(i,a,b) for (int i = a; i < b; i++)
......
66 | FOR(i,0,adj[cv].size()){
| ~~~~~~~~~~~~~~~~~~
stations.cpp:66:5: note: in expansion of macro 'FOR'
66 | FOR(i,0,adj[cv].size()){
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
550 ms |
992 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
610 ms |
736 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
671 ms |
992 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
916 ms |
864 KB |
Output is correct |
2 |
Correct |
761 ms |
736 KB |
Output is correct |
3 |
Incorrect |
617 ms |
864 KB |
Wrong query response. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
559 ms |
992 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |