답안 #314309

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
314309 2020-10-19T15:55:54 Z DanerZein 기지국 (IOI20_stations) C++14
10 / 100
1154 ms 1008 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
#define MAX 1000000000
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
vector<int> labels;
vector<vi> G;
int in[1010],out[1010],vis[1010];
int it=0;
void dfs(int u){
  //it++;
  in[u]=it++;
  vis[u]=1;
  for(auto &v:G[u]){
    if(!vis[v]){
      dfs(v);
    }
  }
  // it++;
  out[u]=it++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
  labels.assign(n,-1);
  G.clear();
  G.resize(n+1);
  int t=u.size();
  for(int i=0;i<t;i++){
    int x=u[i],y=v[i];
    G[x].push_back(y);
    G[y].push_back(x);
  }
  memset(vis,0,sizeof vis);
  memset(in,0,sizeof in);
  memset(out,0,sizeof out);
  dfs(0);
  for(int i=0;i<n;i++){
    int la=in[i]*10000;
    la+=out[i];
    // cout<<in[i]<<" "<<out[i]<<" "<<la<<endl;
    labels[i]=la;
  }
  return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
  int ro=-1,rp=-1;
  int si,ti,so,to;
  si=s/10000; so=s%10000;
  ti=t/10000; to=t%10000;
  bool sub=0;
  int ia,oa;
  for(int i=0;i<c.size();i++){
    if(t==c[i]) return c[i];
    ia=c[i]/10000; oa=c[i]%10000;
    if(si<ia && ia<so){ // si s es padre de c[i]
      if(ia<ti && ti<oa){ //  si c[i] es padre de t
	rp=c[i];
      }
    }
    else{
      ro=c[i];
    }
  }
  if(si<ti && ti<so){ // si s es padre de t
    /* if(rp==-1) {cout<<"s es padre de t "<<s<<" "<<t<<endl;
      for(int i=0;i<c.size();i++) cout<<c[i]<<" ";
      cout<<endl;
    }*/
    return rp;
  }
  else{
    /* if(ro==-1) {cout<<"s es hijo de t "<<s<<" "<<t<<endl;
      for(int i=0;i<c.size();i++) cout<<c[i]<<" ";
      cout<<endl;
    }*/
    return ro;
  }
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:54:16: 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<c.size();i++){
      |               ~^~~~~~~~~
stations.cpp:49:16: warning: variable 'to' set but not used [-Wunused-but-set-variable]
   49 |   int si,ti,so,to;
      |                ^~
stations.cpp:52:8: warning: unused variable 'sub' [-Wunused-variable]
   52 |   bool sub=0;
      |        ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 500 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=70014
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 468 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1991
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 500 KB Invalid labels (values out of range). scenario=1, k=1000000, vertex=1, label=2551480
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 964 ms 760 KB Output is correct
2 Correct 833 ms 768 KB Output is correct
3 Correct 736 ms 884 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 5 ms 768 KB Output is correct
6 Correct 2 ms 768 KB Output is correct
7 Correct 694 ms 688 KB Output is correct
8 Correct 1154 ms 892 KB Output is correct
9 Correct 778 ms 768 KB Output is correct
10 Correct 675 ms 784 KB Output is correct
11 Correct 5 ms 892 KB Output is correct
12 Correct 7 ms 888 KB Output is correct
13 Correct 6 ms 768 KB Output is correct
14 Correct 6 ms 768 KB Output is correct
15 Correct 1 ms 768 KB Output is correct
16 Correct 580 ms 888 KB Output is correct
17 Correct 661 ms 768 KB Output is correct
18 Correct 571 ms 768 KB Output is correct
19 Correct 559 ms 888 KB Output is correct
20 Correct 643 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 664 ms 1008 KB Wrong query response.
2 Halted 0 ms 0 KB -