Submission #332249

# Submission time Handle Problem Language Result Execution time Memory
332249 2020-12-01T19:08:05 Z a_player Colors (RMI18_colors) C++14
0 / 100
987 ms 2924 KB
#include <bits/stdc++.h>

using namespace std;

const int nax=1e5+5;
vector<int> grafo[nax];
int a[nax],b[nax];
int ind[nax];
int c[nax];
bool cmp(int u, int v){
  return a[u]>a[v];
}
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],c[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;
}
}
iota(ind,ind+n,0);
sort(ind,ind+n,cmp);
for(int i=0;i<n;i++){
  if(ind[i]==root)continue;
  if(a[ind[i]]==b[ind[i]])continue;
  if(c[b[ind[i]]]&&b[ind[i]]<=a[root]&&b[ind[i]]<=a[ind[i]]){
    c[a[root]]--;
    a[root]=b[ind[i]];
    c[a[root]]++;
    c[a[ind[i]]]--;
    a[ind[i]]=b[ind[i]];
    c[a[ind[i]]]++;
  }
}
if(c[b[root]]&&b[root]<=a[root])a[root]=b[root];
for(int i=0;i<n;i++)if(a[i]!=b[i]){
  cout<<0<<endl;
  return;
}

cout<<1<<endl;
}

int main(){
int tt;
cin>>tt;
while(tt--)solve();
}

Compilation message

colors.cpp: In function 'void solve()':
colors.cpp:31:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 | if(mas<grafo[i].size()){
      |    ~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 684 ms 2796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 188 ms 2668 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 729 ms 2924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 729 ms 2924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 684 ms 2796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 987 ms 2796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 111 ms 2668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 684 ms 2796 KB Output isn't correct
2 Halted 0 ms 0 KB -