답안 #306596

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
306596 2020-09-26T00:19:45 Z chubyxdxd 기지국 (IOI20_stations) C++14
0 / 100
992 ms 648 KB
#include "stations.h"
#include <iostream>
#include <vector>
using namespace std;
vector<int> label(int n, int k,vector<int> u,vector<int> v) {
  int in[n+10];
  for(int i=0;i<n;i++)in[i]=0;
  for(int i=0;i<n;i++){
    in[v[i]]++;
    in[u[i]]++;
  }
  int piv=0;
  for(int i=0;i<n;i++){
    if(in[i]==1){
      piv=i;
      break;
    }
  }
  //cout<<piv<<endl;
  vector<int> gg;
  gg.push_back(piv);
  for(int i=0;i<n-1;i++){
    for(int j=0;j<u.size();j++){
      if(u[j]==piv){
	gg.push_back(v[j]);
	piv=v[j];
	break;
      }
    }
  }
  if(gg.size()==1){
    for(int i=0;i<n-1;i++){
      for(int j=0;j<u.size();j++){
      if(v[j]==piv){
	gg.push_back(u[j]);
	piv=u[j];
	break;
      }
    }
  }
  }
  //for(auto i:gg)cout<<i<<" ";
  //cout<<endl;
  vector<int> labels(n);
  for(int i=0;i<gg.size();i++){
    //cout<<gg[i]<<" ";
    labels[gg[i]]=i;
  }
  //cout<<endl;
  return labels;
}

int find_next_station(int s, int t,vector<int> c) {
  if(t<s)return s-1;
  else return s+1;
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:23:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int j=0;j<u.size();j++){
      |                 ~^~~~~~~~~
stations.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |       for(int j=0;j<u.size();j++){
      |                   ~^~~~~~~~~
stations.cpp:45:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for(int i=0;i<gg.size();i++){
      |               ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 644 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 992 ms 648 KB Output is correct
2 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -