Submission #132023

#TimeUsernameProblemLanguageResultExecution timeMemory
132023VardanyanMatching (CEOI11_mat)C++14
36 / 100
2072 ms21304 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1000*1000+5; int a[N]; int b[N]; int pos[N]; int main(){ ios_base::sync_with_stdio(false); int n,m; cin>>n>>m; for(int i = 1;i<=n;i++){ cin>>a[i]; pos[i] = a[i]; } for(int i = 1;i<=m;i++) cin>>b[i]; vector<int> ans; set<int> ms; for(int i = 1;i<=n;i++) ms.insert(b[i]); for(int i = 1;i<=m;i++){ if(i+n-1>m) break; int nax = 0; bool f = true; if(*(ms.begin()) == b[pos[1]+i-1] && *(++ms.begin()) == b[pos[2]+i-1] && *(--ms.end()) == b[pos[n]+i-1]){ set<int>::iterator it = ms.begin(); for(int j = 1;j<=n;j++){ int x = pos[j]; if(b[x+i-1]<nax){ f = false; break; } nax = b[x+i-1]; if(*it!=nax) { f = false; break; } it++; } } else f = false; if(f) ans.push_back(i); ms.erase(ms.find(b[i])); ms.insert(b[i+n]); } cout<<ans.size()<<endl; for(int i = 0;i<ans.size();i++) cout<<ans[i]<<" "; cout<<endl; return 0; }

Compilation message (stderr)

mat.cpp: In function 'int main()':
mat.cpp:46:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<ans.size();i++) cout<<ans[i]<<" ";
                   ~^~~~~~~~~~~
#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...