# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
863676 | Andrey | Colors (RMI18_colors) | C++14 | 54 ms | 6764 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
vector<int> col(200001);
vector<int> wow(200001);
vector<int> haha[200001];
vector<bool> bruh(200001);
bool dfs(int a, int c) {
bruh[a] = false;
if(col[a] == c) {
return true;
}
for(int i = 0; i < haha[a].size(); i++) {
if(bruh[haha[a][i]] && wow[haha[a][i]] <= c && col[haha[a][i]] >= c) {
if(dfs(haha[a][i],c)) {
return true;
}
}
}
return false;
}
void solve() {
int n,m,a,b;
cin >> n >> m;
for(int i = 1; i <= n; i++) {
haha[i].clear();
}
vector<pair<int,int>> wut(0);
for(int i = 1; i <= n; i++) {
cin >> col[i];
wut.push_back({col[i],i});
}
sort(wut.begin(),wut.end());
for(int i = 1; i <= n; i++) {
cin >> wow[i];
}
for(int i = 0; i < m; i++) {
cin >> a >> b;
haha[a].push_back(b);
haha[b].push_back(a);
}
for(int i = 0; i < n; i++) {
a = wut[i].second;
if(col[a] != wow[a]) {
cout << 0 << "\n";
return;
}
}
cout << 1 << "\n";
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while(t--) {
solve();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |