Submission #1078282

#TimeUsernameProblemLanguageResultExecution timeMemory
1078282Maite_MoraleSeptember (APIO24_september)C++17
100 / 100
474 ms18112 KiB
#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 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...