# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078961 | Hanksburger | September (APIO24_september) | C++17 | 134 ms | 10448 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |