Submission #1078961

#TimeUsernameProblemLanguageResultExecution timeMemory
1078961HanksburgerSeptember (APIO24_september)C++17
100 / 100
134 ms10448 KiB
#include "september.h" #include <bits/stdc++.h> using namespace std; set<int> buff[5], s; vector<int> p, tmp; int deg[100005]; void process(int u) { if (deg[u]) s.insert(u); else { deg[p[u]]--; while (!deg[p[u]] && s.find(p[u])!=s.end()) { u=p[u]; s.erase(u); deg[p[u]]--; } } } int solve(int n, int m, vector<int> P, vector<vector<int> > a) { p=P; for (int i=1; i<n; i++) deg[p[i]]++; int cnt=0; for (int i=0; i<=n-2; i++) { for (int j=0; j<m; j++) buff[j].insert(a[j][i]); int u=*buff[0].begin(), ok=1; while (1) { for (int j=1; j<m; j++) { if (buff[j].find(u)==buff[j].end()) { ok=0; break; } } if (!ok) break; tmp.push_back(u); for (int j=0; j<m; j++) buff[j].erase(u); if (buff[0].empty()) break; u=*buff[0].begin(); } if (buff[0].empty()) { for (int j=0; j<tmp.size(); j++) process(tmp[j]); tmp.clear(); if (s.empty()) cnt++; } } return cnt; }

Compilation message (stderr)

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:54:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |             for (int j=0; j<tmp.size(); j++)
      |                           ~^~~~~~~~~~~
#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...