답안 #432807

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
432807 2021-06-18T13:27:48 Z Rouge_Hugo 기지국 (IOI20_stations) C++14
0 / 100
900 ms 596 KB
#include<bits/stdc++.h>
#include "stations.h"
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
const int N=1009;
int la[N];
vector<int>v[N];int re=-1;
void dfs(int x,int p)
{
    la[x]=++re;
    for(auto it:v[x])
    {
        if(it==p)continue;
        dfs(it,x);
    }
}
vector<int> label(int n, int k,vector<int> U, vector<int> V) {
	vector<int> l(n);
	for(int  i=0;i<n-1;i++)
    {
        v[U[i]].pb(V[i]);
        v[V[i]].pb(U[i]);
    }
    int root=0;
    for(int i=0;i<n;i++)if(v[i].size()==1)root=i;re=-1;
    dfs(root,-1);
    for(int i=0;i<n;i++)l[i]=la[i];
    memset(la,0,sizeof la);for(int i=0;i<n;i++)v[i].clear();
    return l;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if(s<t)
    {
        return c[1];
    }
    return c[0];
}
/*
1
5 1000000
0 1
1 2
1 3
2 4
2
2 0 1
1 3 3
*/

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:28:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   28 |     for(int i=0;i<n;i++)if(v[i].size()==1)root=i;re=-1;
      |     ^~~
stations.cpp:28:50: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   28 |     for(int i=0;i<n;i++)if(v[i].size()==1)root=i;re=-1;
      |                                                  ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 552 ms 508 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 500 ms 500 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 587 ms 500 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 900 ms 488 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 510 ms 596 KB Wrong query response.
2 Halted 0 ms 0 KB -