# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
873439 |
2023-11-15T05:43:08 Z |
vjudge1 |
Colors (RMI18_colors) |
C++17 |
|
65 ms |
15036 KB |
// #pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define sz(x) (int)x.size()
#define bit(a, i) ((a>>i)&1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int P = 31;
const int K = 400;
const ll inf = 1e9;
const ll INF = 1e18;
const int mod = 1e9+7;
const int maxn = 2e5 + 10;
const int dx[] = {0, 0, -1, 1};
const int dy[] = {1, -1, 0, 0};
int a[maxn];
int b[maxn];
int n, m, sz;
int us[maxn];
vector<int>g[maxn];
map<int, int>dp[maxn];
int dfs(int v, int x){
us[v] = sz;
if(a[v] < x) return 0;
if(b[v] > x) return 0;
if(a[v] == x) return 1;
if(dp[v][x] > 0) return dp[v][x]-1;
int ans = 0;
for(int to: g[v]){
if(us[to] < sz && dfs(to, x)) {
ans = 1;
break;
}
} dp[v][x] = ans + 1;
return ans;
}
void ihtw(){
cin >> n >> m;
for(int i=1; i<=n; i++) cin >> a[i];
for(int i=1; i<=n; i++) {
cin >> b[i];
g[i].clear();
dp[i].clear();
}
for(int i=0; i<m; i++){
int u, v;
cin >> u >> v;
g[u].pb(v);
g[v].pb(u);
}
for(int i=1; i<=n; i++){
sz++;
if(!dfs(i, b[i])){
cout << "0\n";
return;
}
} cout << "1\n";
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t; cin >> t;
while(t--) ihtw();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
14940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
14940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
14936 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
14936 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
14940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
65 ms |
15036 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
14936 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
14940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |