# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
261966 |
2020-08-12T08:33:00 Z |
errorgorn |
Colors (RMI18_colors) |
C++14 |
|
129 ms |
7032 KB |
//雪花飄飄北風嘯嘯
//天地一片蒼茫
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;
#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
int n,m;
int arr[150005];
int brr[150005];
vector<int> al[150005];
set<int> exists;
void solve(){
cin>>n>>m;
rep(x,1,n+1){
al[x].clear();
}
exists.clear();
rep(x,1,n+1) cin>>arr[x];
rep(x,1,n+1) cin>>brr[x];
int a,b;
rep(x,0,m){
cin>>a>>b;
al[a].push_back(b);
al[b].push_back(a);
}
rep(x,1,n+1) exists.insert(arr[x]);
rep(x,1,n+1){
if (!exists.count(brr[x]) || brr[x]>arr[x]){
cout<<0<<endl;
return;
}
}
int root=0;
rep(x,1,n+1){
if (sz(al[x])>sz(al[root])) root=x;
}
rep(x,1,n+1){
if (arr[x]!=brr[x] && (brr[x]<brr[root] || arr[root]<brr[x])){
cout<<0<<endl;
return;
}
}
cout<<1<<endl;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int TC;
cin>>TC;
while (TC--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
5368 KB |
Output is correct |
2 |
Correct |
25 ms |
4480 KB |
Output is correct |
3 |
Correct |
6 ms |
4096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
58 ms |
5624 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
66 ms |
5368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
66 ms |
5368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
5368 KB |
Output is correct |
2 |
Correct |
25 ms |
4480 KB |
Output is correct |
3 |
Correct |
6 ms |
4096 KB |
Output is correct |
4 |
Incorrect |
66 ms |
5368 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
129 ms |
7032 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
4600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
5368 KB |
Output is correct |
2 |
Correct |
25 ms |
4480 KB |
Output is correct |
3 |
Correct |
6 ms |
4096 KB |
Output is correct |
4 |
Incorrect |
58 ms |
5624 KB |
Output isn't correct |