답안 #332250

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
332250 2020-12-01T19:16:55 Z a_player Colors (RMI18_colors) C++14
15 / 100
1046 ms 3308 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 b[u]>b[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];
  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++){
    int x=ind[i];
    if(x==root)continue;
    if(a[x]==b[x])continue;
    for(int j=0;j<n;j++){
      if(b[x]==a[j]&&b[x]<=a[root]&&b[x]<=a[x]){
        a[root]=b[x];
        a[x]=b[x];
        break;
      }
    }
}
for(int i=0;i<n;i++)if(a[i]==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:30:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   if(mas<grafo[i].size()){
      |      ~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 702 ms 2668 KB Output is correct
2 Correct 92 ms 3308 KB Output is correct
3 Correct 7 ms 2796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 194 ms 2668 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 781 ms 2924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 781 ms 2924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 702 ms 2668 KB Output is correct
2 Correct 92 ms 3308 KB Output is correct
3 Correct 7 ms 2796 KB Output is correct
4 Incorrect 781 ms 2924 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1046 ms 2828 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 116 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 702 ms 2668 KB Output is correct
2 Correct 92 ms 3308 KB Output is correct
3 Correct 7 ms 2796 KB Output is correct
4 Incorrect 194 ms 2668 KB Output isn't correct