# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
873467 |
2023-11-15T06:40:17 Z |
vjudge1 |
Colors (RMI18_colors) |
C++17 |
|
83 ms |
12884 KB |
#include<bits/stdc++.h>
using namespace std;
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
#define f first
#define s second
typedef long long ll;
ll A[200100],B[200100];
vector<ll> g[200100];
void solve(){
ll n,m,root=-1; cin>>n>>m;
map<ll, bool> mp;
for(ll i=1; i<=n; i++){
cin>>A[i];
mp[A[i]]=true;
}
for(ll i=1; i<=n; i++) cin>>B[i];
for(ll i=1; i<=m; i++){
ll u,v; cin>>u>>v;
g[u].push_back(v);
g[v].push_back(u);
}
for(ll u=1; u<=n; u++) if(g[u].size() > 1) root=u;
vector<pair<ll, ll>> v;
for(ll i=1; i<=n; i++){
if(root == i) continue;
v.push_back({B[i], A[i]});
}
sort(v.rbegin(), v.rend());
for(auto to: v){
if(A[root] < to.f){
cout<<"0";
return;
}
if(to.s < to.f || !mp[to.f]){
cout<<"0";
return;
}
A[root]=to.f;
}
if(A[root] < B[root] || !mp[B[root]]){
cout<<"0";
return;
}
cout<<"1";
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
cin>>t;
for(int i = 1; i <= t; i++){
// cout<<"Case "<<i<<":\n";
solve();
cout<<'\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
47 ms |
9992 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
38 ms |
12608 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
47 ms |
9808 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
47 ms |
9808 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
47 ms |
9992 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
83 ms |
12884 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
9308 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
47 ms |
9992 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |