답안 #321899

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321899 2020-11-13T13:54:07 Z wildturtle 기지국 (IOI20_stations) C++14
10 / 100
1061 ms 1248 KB
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
int A[1003],l,in[1003],out[1003],don[1003],mp[1003];
vector <int> v1[1003];
vector <int> labels;
void dfs(int x,int y,int z) {
    l++; 
    in[x]=l;
    don[x]=z;
    for(int i=0;i<v1[x].size();i++) {
        if(v1[x][i]==y) continue;
        dfs(v1[x][i],x,z+1);
    }
    l++;
    out[x]=l;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	labels.clear();
	labels.resize(n);
	for(int i=0;i<n;i++) {
	v1[i].clear();
	}
    l=0;
	for(int i=0;i<n-1;i++) {
	    v1[u[i]].push_back(v[i]);
	    v1[v[i]].push_back(u[i]);
	}
	dfs(0,-1,0);
	for(int i=0;i<n;i++) {
	    if(don[i]%2==0) A[i]=in[i];
	    else A[i]=out[i];
	}
	sort(A,A+n);
	for(int i=0;i<n;i++) {
	    mp[A[i]]=i;
	}
	for(int i=0;i<n;i++) {
	    if(don[i]%2==0) labels[i]=mp[in[i]];
	    else labels[i]=mp[out[i]];
	}
	return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
    if(s<c[0]) {
        for(int i=0;i<c.size()-1;i++) {
            if(i==0) {
                if(s+1<=t && t<=c[i]) return c[i];
            }
            else if(c[i-1]+1<=t && t<=c[i]) return c[i];
        }
        return c[c.size()-1];
    }
    else {
        for(int i=0;i<c.size();i++) {
            if(i==c.size()-1) {
                if(c[i]<=t && t<=s-1) return c[i];
            }
            else if(c[i]<=t && t<=c[i+1]-1) return c[i];
        }
        return c[0];
    }
}

Compilation message

stations.cpp: In function 'void dfs(int, int, int)':
stations.cpp:11:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i=0;i<v1[x].size();i++) {
      |                 ~^~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         for(int i=0;i<c.size()-1;i++) {
      |                     ~^~~~~~~~~~~
stations.cpp:55:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         for(int i=0;i<c.size();i++) {
      |                     ~^~~~~~~~~
stations.cpp:56:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |             if(i==c.size()-1) {
      |                ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 636 KB Invalid labels (duplicates values). scenario=2, label=0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 364 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 540 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1019 ms 864 KB Output is correct
2 Correct 672 ms 1248 KB Output is correct
3 Correct 708 ms 864 KB Output is correct
4 Correct 3 ms 972 KB Output is correct
5 Correct 5 ms 736 KB Output is correct
6 Correct 2 ms 1060 KB Output is correct
7 Correct 769 ms 932 KB Output is correct
8 Correct 1061 ms 932 KB Output is correct
9 Correct 701 ms 932 KB Output is correct
10 Correct 569 ms 736 KB Output is correct
11 Correct 6 ms 992 KB Output is correct
12 Correct 6 ms 864 KB Output is correct
13 Correct 4 ms 940 KB Output is correct
14 Correct 5 ms 748 KB Output is correct
15 Correct 2 ms 868 KB Output is correct
16 Correct 713 ms 736 KB Output is correct
17 Correct 542 ms 876 KB Output is correct
18 Correct 680 ms 864 KB Output is correct
19 Correct 580 ms 932 KB Output is correct
20 Correct 775 ms 880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 524 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -