Submission #741667

#TimeUsernameProblemLanguageResultExecution timeMemory
741667vjudge1Dreaming (IOI13_dreaming)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "dreaming.h" using namespace std; #define endl '\n' #define ll long long #define all(x) x.begin(), x.end() vector<pair<int, int>> g[100005]; ll sz[100005]; vector<int> group; int getSize(int n, int p = -1) { visited[n] = 1; group.push_back(n); sz[n] = 0; for (auto x : g[n]) { if (x.first == p) conitnue; sz[n] += getSize(x.first, n) + x.second; } return sz[n]; } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { for (int i = 0; i < M; i++) { g[A[i]].push_back({B[i], T[i]}); g[B[i]].push_back({A[i], T[i]}); } bool visited[N + 2]; vector<int> groups; for (int i = 0; i < N; i++) { if (visited[i]) continue; group.clear(); getSize(i); int diff = INT_MAX; for (auto x : group) { if (abs(sz[i] / 2 - sz[x]) < diff) { diff = abs(sz[i] / 2 - sz[x]); } } group.push_back(diff); } sort(all(group)); reverse(all(group)); int ans = 0; for (int i = 1; i < group.size(); i++) { ans = max(ans, group[i] + group[0] + L); } return ans; }

Compilation message (stderr)

dreaming.cpp: In function 'int getSize(int, int)':
dreaming.cpp:15:5: error: 'visited' was not declared in this scope
   15 |     visited[n] = 1;
      |     ^~~~~~~
dreaming.cpp:19:27: error: 'conitnue' was not declared in this scope
   19 |         if (x.first == p) conitnue;
      |                           ^~~~~~~~
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:47:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for (int i = 1; i < group.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~