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 <cstring>
#include <vector>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int N = 100000;
int gg[N], dd[N];
int solve(int n, int m, vi pp, vector<vi> iii) {
for (int g = 0; g < n - 1; g++)
gg[iii[0][g]] = g;
gg[0] = n - 1;
memset(dd, 0, n * sizeof *dd);
for (int h = 1; h < m; h++)
for (int g = 0; g < n - 1; g++) {
int g_ = gg[iii[h][g]];
if (g < g_)
dd[g]++, dd[g_]--;
else
dd[g_]++, dd[g]--;
}
for (int j = 1; j < n; j++) {
int i = pp[j];
if (gg[i] < gg[j])
dd[gg[i]]++, dd[gg[j]]--;
}
for (int g = 1; g < n; g++)
dd[g] += dd[g - 1];
int cnt = 0;
for (int g = 0; g < n - 1; g++)
if (dd[g] == 0)
cnt++;
return cnt;
}
# | 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... |