# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1110674 |
2024-11-10T07:38:37 Z |
Ciprian |
Colors (RMI18_colors) |
C++14 |
|
76 ms |
2120 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin>>t;
for(int i=0; i<t; i++){
int n,m;
cin>>n>>m;
vector<int> adj[n+3], deg(n+3), a(n+2), b(n+1);
for(int j=1; j<=n; j++){
cin>>a[j];
}for(int j=1; j<=n; j++){
cin>>b[j];
}bool check=true;
for(int j=1; j<=n; j++){
if(b[j]>a[j]){
check=false;
}
}
for(int j=0; j<m; j++){
int u,v;
cin>>u>>v;
adj[u].push_back(v);
adj[v].push_back(u);
deg[u]++;
deg[v]++;
}int r=0;
for(int j=1; j<=n; j++){
if(deg[j]>1){
r=j;
break;
}
}set<int> c;
c.insert(a[r]);
for(int j=1; j<=n; j++){
if(j!=r){
if(a[j]<=a[r] &&b[r]<=a[j]){
c.insert(a[j]);
}
}
}if(!check){
cout<<0<<endl;
}else if(m==n-1){
bool res=true;
for(int j=1; j<=n; j++){
if(j!=r){
if(a[j]!=b[j]){
if(c.find(b[j])==c.end()){
res=false;
break;
}
}
}
}cout<<res<<endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
1372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
1352 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
1352 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
76 ms |
2120 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |