Submission #863673

#TimeUsernameProblemLanguageResultExecution timeMemory
863673AndreyColors (RMI18_colors)C++14
47 / 100
3051 ms10436 KiB
#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; } for(int j = 1; j <= n; j++) { bruh[j] = true; } if(!dfs(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)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...