Submission #332253

# Submission time Handle Problem Language Result Execution time Memory
332253 2020-12-01T19:21:25 Z a_player Colors (RMI18_colors) C++14
7 / 100
978 ms 2880 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];
  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;
  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);
  }

  
  iota(ind,ind+n,0);
  sort(ind,ind+n,cmp);
  for(int i=0;i<n;i++){
    int x=ind[i];
    if(a[x]==b[x])continue;
    for(int j=0;j<n;j++){
      if(b[x]==a[j]&&b[x]<=a[x]){
        a[x]=b[x];
      }
    }
}

  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();
  }
# Verdict Execution time Memory Grader output
1 Incorrect 694 ms 2796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 190 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 698 ms 2668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 698 ms 2668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 694 ms 2796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 978 ms 2880 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 114 ms 2668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 694 ms 2796 KB Output isn't correct
2 Halted 0 ms 0 KB -