# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
332256 |
2020-12-01T19:45:36 Z |
a_player |
Colors (RMI18_colors) |
C++14 |
|
993 ms |
3108 KB |
#include <bits/stdc++.h>
using namespace std;
const int nax=1e5+5;
vector<int> grafo[nax];
int a[nax],b[nax];
int ind[nax];
bool vv[nax];
bool p[nax];
bool cmp(int u, int v){
return b[u]>b[v];
}
bool dfs(int n, int in){
if(a[n]==b[in])return true;
if(vv[n])return false;
vv[n]=1;
for(int x:grafo[n])
if((a[x]>b[in]&&!p[x])||(a[x]==b[in]))
if(dfs(x,in)){
a[x]=b[in];
return true;
}
return false;
}
void solve(){
for(int i=0;i<nax;i++){
p[i]=0;
grafo[i].clear();
}
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++)cin>>b[i];
for(int i=0;i<m;i++){
int u,v;
cin>>u>>v;
u--,v--;
grafo[u].push_back(v);
grafo[v].push_back(u);
}
iota(ind,ind+n,0);
sort(ind,ind+n,cmp);
for(int i=0;i<n;i++){
for(int i=0;i<n;i++)vv[i]=0;
int x=ind[i];
if(!dfs(x,x)){
cout<<0<<endl;
return;
}
p[x]=1;
}
for(int i=0;i<n;i++)if(a[i]!=b[i]){
cout<<0<<endl;
return;
}
cout<<1<<endl;
}
int main(){
int tt;
cin>>tt;
while(tt--)solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
696 ms |
3052 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
194 ms |
2796 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
698 ms |
2924 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
698 ms |
2924 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
696 ms |
3052 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
993 ms |
3108 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
123 ms |
2816 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
696 ms |
3052 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |