#include<bits/stdc++.h>
#include "swap.h"
//#include "grader.cpp"
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int>vi;
typedef vector<vector<int>>vvi;
typedef vector<ll>vl;
typedef vector<vl> vvl;
typedef pair<int,int>pi;
typedef pair<ll,ll> pl;
typedef vector<pl> vpl;
typedef vector<ld> vld;
typedef pair<ld,ld> pld;
//typedef tree<ll, null_type, less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<typename T> ostream& operator<<(ostream& os, vector<T>& a){os<<"[";for(int i=0; i<ll(a.size()); i++){os << a[i] << ((i!=ll(a.size()-1)?" ":""));}os << "]\n"; return os;}
#define all(x) x.begin(),x.end()
#define YES out("YES")
#define NO out("NO")
#define out(x){cout << x << "\n"; return;}
#define GLHF ios_base::sync_with_stdio(false); cin.tie(NULL)
#define print(x){for(auto ait:x) cout << ait << " "; cout << "\n";}
#define pb push_back
#define umap unordered_map
vector<vector<pi>> g;
vector<bool>vis;
int mx=-1;
bool cyc=1;
void init(int n, int M,vi U,vi V,vi W){
g.resize(n);
vis.resize(n);
mx=*max_element(all(W))+1;
for(int i=0; i<M; i++){
g[U[i]].pb({V[i],W[i]});
g[V[i]].pb({U[i],W[i]});
}
for(int i=0; i<n; i++)
cyc&=g[i].size()==2;
}
bool ans;
void dfs(int src,int par,int w){
vis[src]=1;
int cnt=0;
for(pi nbr:g[src])
if(nbr.second<=w)
cnt++;
if(cnt>2)
ans=1;
for(pi nbr:g[src]) {
if(nbr.first==par || nbr.second>w)continue;
if(vis[nbr.first])ans=1;
else dfs(nbr.first,src,w);
}
}
bool ok(int x,int y,int w){
int n=g.size();
for(int i=0; i<n; i++)
vis[i]=false;
ans=0;
dfs(x,-1,w);
if(!vis[y])return 0;
return ans;
}
int getMinimumFuelCapacity(int X, int Y){
if(!cyc)return -1;
else return mx-1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
41 ms |
6416 KB |
Output is correct |
10 |
Correct |
49 ms |
7804 KB |
Output is correct |
11 |
Correct |
55 ms |
7640 KB |
Output is correct |
12 |
Correct |
75 ms |
8124 KB |
Output is correct |
13 |
Correct |
66 ms |
8124 KB |
Output is correct |
14 |
Correct |
47 ms |
6472 KB |
Output is correct |
15 |
Correct |
112 ms |
14000 KB |
Output is correct |
16 |
Correct |
118 ms |
13724 KB |
Output is correct |
17 |
Correct |
121 ms |
14252 KB |
Output is correct |
18 |
Correct |
115 ms |
14216 KB |
Output is correct |
19 |
Correct |
64 ms |
6980 KB |
Output is correct |
20 |
Correct |
112 ms |
14916 KB |
Output is correct |
21 |
Correct |
126 ms |
15036 KB |
Output is correct |
22 |
Correct |
129 ms |
15660 KB |
Output is correct |
23 |
Correct |
127 ms |
15644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
102 ms |
10140 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
41 ms |
6416 KB |
Output is correct |
10 |
Correct |
49 ms |
7804 KB |
Output is correct |
11 |
Correct |
55 ms |
7640 KB |
Output is correct |
12 |
Correct |
75 ms |
8124 KB |
Output is correct |
13 |
Correct |
66 ms |
8124 KB |
Output is correct |
14 |
Correct |
47 ms |
6472 KB |
Output is correct |
15 |
Correct |
112 ms |
14000 KB |
Output is correct |
16 |
Correct |
118 ms |
13724 KB |
Output is correct |
17 |
Correct |
121 ms |
14252 KB |
Output is correct |
18 |
Correct |
115 ms |
14216 KB |
Output is correct |
19 |
Incorrect |
102 ms |
10140 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |