# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
260347 |
2020-08-10T06:18:27 Z |
dvdg6566 |
Colors (RMI18_colors) |
C++14 |
|
569 ms |
3652 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 = 1600;
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 col=1;col<=N;++col){
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 |
210 ms |
1912 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
214 ms |
2040 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
225 ms |
1912 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
225 ms |
1912 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
210 ms |
1912 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
569 ms |
3652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
102 ms |
1144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
210 ms |
1912 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |