제출 #413415

#제출 시각아이디문제언어결과실행 시간메모리
413415Bench0310Matching (CEOI11_mat)C++17
0 / 100
172 ms10640 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(0); cin.tie(0); int n,m; cin >> n >> m; vector<int> s(n+1,0); for(int i=1;i<=n;i++) cin >> s[i]; vector<int> h(m+1,0); for(int i=1;i<=m;i++) cin >> h[i]; deque<int> d; auto add=[&](int i) { while(!d.empty()&&h[d.back()]>h[i]) d.pop_back(); d.push_back(i); }; auto rm=[&](int i) { if(!d.empty()&&d.front()==i) d.pop_front(); }; vector<int> res; ll t=0; auto ch=[&](int l) { t+=n; return; vector<array<int,2>> v; for(int i=l;i<=l+n-1;i++) v.push_back({h[i],i-l+1}); sort(v.begin(),v.end()); bool ok=1; for(int i=0;i<n;i++) ok&=(v[i][1]==s[i+1]); if(ok) res.push_back(l); }; for(int i=1;i<n;i++) add(i); for(int i=n;i<=m;i++) { add(i); int l=i-n+1; if(l+s[1]-1==d.front()) ch(l); rm(l); } assert(t<=m); cout << res.size() << "\n"; for(int a:res) cout << a << " "; cout << "\n"; 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...