Submission #1046589

#TimeUsernameProblemLanguageResultExecution timeMemory
1046589gry3125September (APIO24_september)C++17
100 / 100
120 ms10452 KiB
#include "september.h" #include <bits/stdc++.h> using namespace std; int solve(int N, int M, vector<int> F, vector<vector<int>> S) { vector<int> leafs(N); for (int i = 1; i < N; i++) { leafs[F[i]] += M; } set<int> uwu, hasleaf; int size = 0; int k = 0; for (int i = 0; i < N-1; i++) { size++; for (int j = 0; j < M; j++) { uwu.insert(S[j][i]); hasleaf.insert(S[j][i]); leafs[F[S[j][i]]]--; if (leafs[S[j][i]] == 0) { hasleaf.erase(S[j][i]); } if (leafs[F[S[j][i]]] == 0) { hasleaf.erase(F[S[j][i]]); } } if (uwu.size() == size && hasleaf.size() == 0) { size = 0; uwu.clear(); k++; } } return k; }

Compilation message (stderr)

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:28:18: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |   if (uwu.size() == size && hasleaf.size() == 0) {
      |       ~~~~~~~~~~~^~~~~~~
#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...