Submission #863676

# Submission time Handle Problem Language Result Execution time Memory
863676 2023-10-20T17:23:28 Z Andrey Colors (RMI18_colors) C++14
0 / 100
54 ms 6764 KB
#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

colors.cpp: In function 'bool dfs(int, int)':
colors.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i = 0; i < haha[a].size(); i++) {
      |                    ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 6764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 6744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -