Submission #285446

# Submission time Handle Problem Language Result Execution time Memory
285446 2020-08-29T02:45:24 Z DanerZein Split the Attractions (IOI19_split) C++14
0 / 100
64 ms 8824 KB
#include "split.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
vector<vi> G;
int vis[100010];
bool sw=0;
int ca;
vi pat;
void dfs(int u,int cas){
  if(ca<=0){
    sw=1;
    return;
  }
  ca--;
  vis[u]=cas;
  pat.push_back(u);
  for(auto &v:G[u]){
    if(vis[v]!=cas and vis[v]!=-1){
      dfs(v,cas);
    }
  }
  //vis[u]=0;
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
  G.resize(n+1);
  for(int i=0;i<p.size();i++){
    G[p[i]].push_back(q[i]);
    G[q[i]].push_back(p[i]);
  }
  vector<ii> aux;
  aux.push_back(ii(a,1));
  aux.push_back(ii(b,2));
  aux.push_back(ii(c,3));
  sort(aux.begin(),aux.end());
  int id;
  for(int i=0;i<G.size();i++){
    if(G[i].size()==1){
      id=i;
      break;
    }
  }
  memset(vis,0,sizeof vis);
  ca=aux[0].first;
  dfs(id,-1);
  bool res=0;
  vector<int> r;
  r.resize(n);
  if(sw==0){
    res=1;
  }
  else{
    for(int i=0;i<pat.size();i++){
      r[pat[i]]=aux[0].second;
    }
  }
  int cas=1;
  for(int i=0;i<n;i++){
    if(!vis[i]){
      sw=0;
      ca=aux[1].first;
      //cout<<ca<<endl;
      pat.clear();
      dfs(i,cas);
      cas++;
      if(sw==1){
	for(int i=0;i<pat.size();i++){
	  r[pat[i]]=aux[1].second;
	}
	break;
      }
    }
  }
  if(sw==0){
    res=1;
  }
  if(res==1){
    for(int i=0;i<n;i++){
      r.push_back(0);
    }
  }
  else{
    for(int i=0;i<n;i++){
      if(r[i]==0){
	r[i]=aux[2].second;
      }
    }
  }
  return r;
}

Compilation message

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:28:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   for(int i=0;i<p.size();i++){
      |               ~^~~~~~~~~
split.cpp:38:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   for(int i=0;i<G.size();i++){
      |               ~^~~~~~~~~
split.cpp:54:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for(int i=0;i<pat.size();i++){
      |                 ~^~~~~~~~~~~
split.cpp:68:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |  for(int i=0;i<pat.size();i++){
      |              ~^~~~~~~~~~~
split.cpp:46:6: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
   46 |   dfs(id,-1);
      |   ~~~^~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 768 KB ok, correct split
2 Incorrect 1 ms 896 KB WA in grader: Invalid length of the result.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 640 KB ok, correct split
2 Incorrect 1 ms 768 KB WA in grader: Invalid length of the result.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 640 KB ok, correct split
2 Incorrect 64 ms 8824 KB WA in grader: Invalid length of the result.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 640 KB WA in grader: Invalid length of the result.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 768 KB ok, correct split
2 Incorrect 1 ms 896 KB WA in grader: Invalid length of the result.
3 Halted 0 ms 0 KB -