#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_multiset tree<long long, null_type,less_equal<long long>, rb_tree_tag,tree_order_statistics_node_update>
//#define ordered_set tree<long long, null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
//st.order_of_key
//st.find_by_order
main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
int n,m;
cin>>n>>m;
vector<int> a(n+1);
for(int i=1;i<=n;++i){
cin>>a[i];
}
vector<int> b(m+1),c(n+1),d(m+1),ans;
int l,r,mid,i,j;
for(i=1;i<=m;++i){
cin>>b[i];
if(i>n){
for(j=d[i-n]+1;j<=n;++j){
d[c[j]]=j-1;
c[j-1]=c[j];
}
}
l=0,r=min(i,n);
while(l<r-1){
mid=(l+r)/2;
if(b[c[mid]]<b[i]){
l=mid;
}else{
r=mid;
}
}
for(j=min(i,n);j>r;--j){
c[j]=c[j-1];
d[c[j]]=j;
}
c[r]=i;
d[i]=r;
if(i>=n){
ans.push_back(i-n+1);
for(j=1;j<=n;++j){
if(c[j]-i+n!=a[j]){
ans.pop_back();
break;
}
}
}
}
cout<<ans.size()<<"\n";
for(int i:ans){
cout<<i<<" ";
}
}
컴파일 시 표준 에러 (stderr) 메시지
mat.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
15 | main(){
| ^~~~
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |