Submission #332245

#TimeUsernameProblemLanguageResultExecution timeMemory
332245a_playerColors (RMI18_colors)C++14
0 / 100
1028 ms2896 KiB
#include <bits/stdc++.h> using namespace std; const int nax=1e5+5; vector<int> grafo[nax]; int a[nax],b[nax]; void solve(){ for(int i=0;i<nax;i++){ grafo[i].clear(); } int n,m; cin>>n>>m; int root=-1; for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<n;i++)cin>>b[i]; for(int i=0;i<m;i++){ int u,v; cin>>u>>v; u--,v--; grafo[u].push_back(v); grafo[v].push_back(u); } int mas=0; for(int i=0;i<n;i++){ if(mas<grafo[i].size()){ mas=grafo[i].size(); root=i; } } if(a[root]!=b[root]){ for(int i=0;i<n;i++)if(min(a[i],a[root])==b[root])a[root]=min(a[i],a[root]),i=n; if(a[root]!=b[root]){ cout<<0<<endl; return; } } for(int i=0;i<n;i++){ if(a[i]!=b[i]&&min(a[i],a[root])!=b[i]){ cout<<0<<endl; return; } } cout<<1<<endl; } int main(){ int tt; cin>>tt; while(tt--)solve(); }

Compilation message (stderr)

colors.cpp: In function 'void solve()':
colors.cpp:26:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |       if(mas<grafo[i].size()){
      |          ~~~^~~~~~~~~~~~~~~~
#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...