#include <bits/stdc++.h>
using namespace std;
int solve(int n, int m, vector<int> p, vector<vector<int>> s) {
vector<set<int>> a(m);
int k = 0;
set<int> o;
vector<int> l(n);
queue<int> q;
for (int i : p) if (i > -1) l[i]++;
for (int i = 0; i < s[0].size(); ++i) {
bool z = true;
for (int j = 0; j < m; ++j) {
a[j].insert(s[j][i]);
if (j) z &= a[j] == a[j - 1];
if (!o.count(s[j][i]) && s[j][i]) l[p[s[j][i]]]--;
o.insert(s[j][i]);
if (l[s[j][i]]) q.push(s[j][i]);
}
while (q.size() && !l[q.front()]) q.pop();
k += q.empty() && z;
if(z) for (auto &j : a) j.clear();
}
return k;
}
# | 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... |