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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vll vector<ll>
#define MAX 500005
#define oo 10000000000
int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) {
vll a(N-1,0),mn(N,oo),mx(N,0);
for(int i=0;i<N-1;i++)a[i]=i;
for(int i=0;i<M;i++){
map<ll,ll> mp;
for(int j=0;j<N-1;j++){
mp[S[i][j]]=j;
mn[S[i][j]]=min(mn[S[i][j]],(ll)j);
mx[S[i][j]]=max(mx[S[i][j]],(ll)j);
}
for(int j=0;j<N-1;j++){
if(F[S[i][j]]!=0)a[mp[F[S[i][j]]]]=max(a[mp[F[S[i][j]]]],(ll)j);
}
}
for(int j=1;j<N;j++){
a[mn[j]]=max(a[mn[j]],mx[j]);
}
ll K=0,limit=0;
for(int i=0;i<N-1;i++){
//cout<<a[i]<<" ";
limit=max(limit,a[i]);
if(limit==i)K++;
}
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... |