답안 #402522

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
402522 2021-05-11T22:05:49 Z Dan4Life 기지국 (IOI20_stations) C++17
0 / 100
2 ms 320 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector<int> adj[1001], col(1001);
int lab = 0;
void dfs(int s, int p)
{
    if(col[s]!=-1)return;
    col[s]=lab; lab++;
    for(auto u : adj[s])
        if(u!=p) dfs(u, s);
}

vector<int> label(int n, int k, vector<int> a, vector<int> b)
{
    col.resize(n); lab=0;
    for(int i = 0; i < 1001; i++) adj[i].clear(), col[i]=-1;
	for (int i = 0; i < n; i++) {
		adj[a[i]].pb(b[i]);
		adj[b[i]].pb(a[i]);
	}
	for(int i = 0; i < n; i++){
        if(adj[i].size()==1){
            dfs(i, -1); break;
        }
	}
	for(auto u : col) cout << u << " "; cout << '\n';
	return col;
}

int find_next_station(int s, int t, vector<int> c)
{
	if(c.size()==1)return c[0];
	for(int i = 0; i < (int)c.size(); i++)
        if(c[i]==t)return c[i];
	if(t<s)return c[0];
	return c[1];
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:28:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   28 |  for(auto u : col) cout << u << " "; cout << '\n';
      |  ^~~
stations.cpp:28:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   28 |  for(auto u : col) cout << u << " "; cout << '\n';
      |                                      ^~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 312 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 320 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 316 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 296 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -