답안 #403160

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
403160 2021-05-12T20:35:19 Z AmineTrabelsi 기지국 (IOI20_stations) C++14
5 / 100
1126 ms 620 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int Mx = 1010;
void dfs(int node,int par,vector<int> &labels,vector<vector<int>> &tr){
    for(auto i:tr[node]){
        if(i != par){
            labels[i] = labels[node]+1;
            dfs(i,node,labels,tr);
        }
    }
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    vector<int> labels(n);
    vector<vector<int>> tr(n+1,vector<int>(0));
	for (int i = 0; i < n-1; i++) {
		tr[u[i]].push_back(v[i]);
        tr[v[i]].push_back(u[i]);
	}
    int root = 0;
    for(int i=0;i<n;i++){
        if(tr[i].size() == 1){
            root = i;
            break;
        }
    }
    dfs(root,-1,labels,tr);
	return labels;
}
int find_next_station(int s, int t, vector<int> c) {
    if(t <= s)
        return *min_element(c.begin(),c.end());
	return *max_element(c.begin(),c.end());
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:31:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   31 |     if(t <= s)
      |     ^~
stations.cpp:33:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   33 |  return *max_element(c.begin(),c.end());
      |  ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 688 ms 528 KB Output is correct
2 Correct 506 ms 612 KB Output is correct
3 Correct 1007 ms 484 KB Output is correct
4 Correct 691 ms 400 KB Output is correct
5 Correct 599 ms 488 KB Output is correct
6 Correct 655 ms 616 KB Output is correct
7 Correct 520 ms 528 KB Output is correct
8 Correct 3 ms 480 KB Output is correct
9 Correct 5 ms 468 KB Output is correct
10 Correct 2 ms 476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 272 KB Invalid labels (duplicates values). scenario=0, label=10
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 713 ms 616 KB Output is correct
2 Correct 542 ms 620 KB Output is correct
3 Correct 1126 ms 488 KB Output is correct
4 Correct 689 ms 504 KB Output is correct
5 Correct 757 ms 400 KB Output is correct
6 Correct 489 ms 540 KB Output is correct
7 Correct 492 ms 528 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 6 ms 468 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Incorrect 1 ms 284 KB Invalid labels (duplicates values). scenario=1, label=2
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1073 ms 400 KB Output is correct
2 Correct 790 ms 400 KB Output is correct
3 Correct 667 ms 400 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 5 ms 464 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Incorrect 1 ms 288 KB Invalid labels (duplicates values). scenario=0, label=2
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 630 ms 520 KB Output is correct
2 Correct 470 ms 528 KB Output is correct
3 Correct 978 ms 400 KB Output is correct
4 Correct 752 ms 400 KB Output is correct
5 Correct 656 ms 488 KB Output is correct
6 Correct 537 ms 528 KB Output is correct
7 Correct 505 ms 616 KB Output is correct
8 Correct 4 ms 464 KB Output is correct
9 Correct 4 ms 480 KB Output is correct
10 Correct 2 ms 476 KB Output is correct
11 Incorrect 5 ms 268 KB Invalid labels (duplicates values). scenario=0, label=10
12 Halted 0 ms 0 KB -