# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
260351 |
2020-08-10T06:25:48 Z |
dvdg6566 |
Colors (RMI18_colors) |
C++14 |
|
498 ms |
4344 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MOD = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 160000;
const ll BSIZ= 800;
int T,N,E,a,b;
int A[MAXN];
int B[MAXN];
vi V[MAXN];
int vis[MAXN];
void dfs(int x,int col){
vis[x]=1;
for(auto v:V[x])if(!vis[v]){
if(B[v]>col)continue;
dfs(v,col);
}
}
int main(){
cin>>T;
while(T--){
cin>>N>>E;
for(int i=1;i<=N;++i){
V[i].clear();
cin>>A[i];
}
for(int i=1;i<=N;++i)cin>>B[i];
for(int i=0;i<E;++i){cin>>a>>b;V[a].pb(b);V[b].pb(a);}
int ans=1;
for(int i=1;i<=N;++i)if(B[i]>A[i])ans=0;
for(int col=1;col<=N;++col)if(ans){
for(int j=1;j<=N;++j)vis[j]=0;
for(int j=1;j<=N;++j)if(!vis[j]&&A[j]==col)dfs(j,col);
for(int j=1;j<=N;++j)if(B[j]==col&&!vis[j]){
ans=0;
break;
}
}
cout<<ans<<'\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
209 ms |
4096 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
214 ms |
4096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
223 ms |
4216 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
223 ms |
4216 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
209 ms |
4096 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
498 ms |
4344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
117 ms |
4096 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
209 ms |
4096 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |