Submission #1010406

#TimeUsernameProblemLanguageResultExecution timeMemory
1010406sleepntsheepSeptember (APIO24_september)C++17
100 / 100
150 ms17612 KiB
#include "september.h" #include <cstdio> #include <algorithm> #include <vector> #include <array> int solve(int N, int M, std::vector<int> P/* F is patriarchy ! */, std::vector<std::vector<int>> S) { using i5 = std::array<int, 5>; std::vector<int> vis(N); std::vector<std::vector<int> > g(N); for (int i = 1; i < N; ++i) g[P[i]].push_back(i); std::vector<std::vector<int> > SI(M, std::vector<int>(N)); for (int i = 0; i < M; ++i) for (int j = 0; j < N - 1; ++j) SI[i][S[i][j]] = j; i5 at {}, at2 {}, at3; auto dfs = [&](auto &&dfs, int u) -> void { if (vis[u]) return; vis[u] = 1; for (int i = 0; i < M; ++i) at2[i] = std::max(at2[i], SI[i][u] + 1); for (auto v : g[u]) dfs(dfs, v); }; auto sheep = [&]() { for (int i = 0; i < M; ++i) at2[i] = std::min(N - 1, at[i] + 1); while (at != at2) { at3 = at2; for (int i = 0; i < M; ++i) { for (int j = at[i]; j < at2[i]; ++j) dfs(dfs, S[i][j]); } at = at3; } }; int K = 0; for (; *std::min_element(at.begin(), at.begin() + M) < N - 1; ++K) sheep(); return K; }

Compilation message (stderr)

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:49:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   49 |     for (; *std::min_element(at.begin(), at.begin() + M) < N - 1; ++K)
      |     ^~~
september.cpp:52:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   52 |  return K;
      |  ^~~~~~
#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...
#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...