Submission #335840

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
3358402020-12-14 05:42:25aanastasovStations (IOI20_stations)C++17
100 / 100
988 ms1208 KiB
#include "stations.h"
#include <algorithm>
#include <cassert>
//#include <iostream>
#include <vector>
void dfs(int src, int parent, int depth, std::vector<std::vector<int>>& adj,
int& nextLabel, std::vector<int>& labels) {
if (depth % 2 == 0) {
labels[src] = nextLabel++;
}
for (int dst : adj[src]) {
if (dst == parent) continue;
dfs(dst, src, depth + 1, adj, nextLabel, labels);
}
if (depth % 2 == 1) {
labels[src] = nextLabel++;
}
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
assert(n <= k);
auto adj = std::vector<std::vector<int>>(n, std::vector<int>());
assert(u.size() == v.size());
for (int index = 0; index < u.size(); ++index) {
adj[u[index]].push_back(v[index]);
adj[v[index]].push_back(u[index]);
}
auto labels = std::vector<int>(n, -1);
int nextLabel = 0;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:25:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int index = 0; index < u.size(); ++index) {
      |                         ~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...