Submission #902696

#TimeUsernameProblemLanguageResultExecution timeMemory
902696Darren0724Matching (CEOI11_mat)C++17
36 / 100
2056 ms20212 KiB
#include <bits/stdc++.h> using namespace std; #define LCBorz ios_base::sync_with_stdio(false); cin.tie(0); #define all(x) x.begin(), x.end() const int N=200005; int32_t main() { LCBorz; int n,m;cin>>n>>m; vector<int> a1(n),a(n),b(m),ans; int idx=0; for(int i=0;i<n;i++){ cin>>a1[i]; } for(int i=0;i<n;i++){ a[a1[i]-1]=i+1; } for(int i=0;i<n;i++){ idx=(a[i]==1?i:idx); } for(int j=0;j<m;j++){ cin>>b[j]; } deque<int> dq; for(int i=0;i<m;i++){ while(dq.size()&&dq.front()<=i-n){ dq.pop_front(); } while(dq.size()&&b[dq.back()]>b[i]){ dq.pop_back(); } dq.push_back(i); if(i>=n-1&&dq.front()-i+(n-1)==idx){ vector<int> t; for(int j=0;j<n;j++){ t.push_back(b[i-(n-1)+j]); } sort(all(t)); int flag=1; for(int j=0;j<n;j++){ if(b[i-(n-1)+j]!=t[a[j]-1]){ flag=0; } } if(flag)ans.push_back(i-(n-2)); } } cout<<ans.size()<<endl; for(int j:ans){ cout<<j<<' '; } cout<<endl; return 0; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...