# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
261716 |
2020-08-12T02:57:11 Z |
lyc |
Colors (RMI18_colors) |
C++14 |
|
1757 ms |
5368 KB |
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)
const int mxN = 150005;
const int inf = 2e5+5;
int N, M, A[mxN], B[mxN];
vector<int> al[mxN];
bool reach[mxN];
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int TC; cin >> TC;
while (TC--) {
cin >> N >> M;
FOR(i,1,N){ cin >> A[i]; }
FOR(i,1,N){ cin >> B[i]; }
FOR(i,1,N) al[i].clear();
FOR(i,1,M){
int U, V; cin >> U >> V;
al[U].push_back(V);
al[V].push_back(U);
}
bool ok = 1;
FOR(s,1,N){
queue<int> q;
memset(reach,0,sizeof reach);
q.push(s), reach[s] = 1;
while (!q.empty()) {
int u = q.front(); q.pop();
for (int& v : al[u]) if (!reach[v] && A[v] >= B[s] && B[v] <= B[s]) {
reach[v] = 1;
q.push(v);
}
}
bool cur = 0;
FOR(v,1,N) if (reach[v] && A[v] == B[s]) { cur = 1; break; }
ok &= cur;
}
cout << ok << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
841 ms |
5368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
188 ms |
5284 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
839 ms |
5240 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
839 ms |
5240 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
841 ms |
5368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1757 ms |
5256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
127 ms |
4644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
841 ms |
5368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |