This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define taskname "bai3"
#define int long long
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define pii pair<int, int>
using namespace std;
const int mxN = 1e6 + 5;
const int mod = 1e9 + 7;
const int oo = 1e18;
int n, m, sx[mxN], a[mxN];
void solve(){
cin >> n >> m;
for(int i = 1; i <= n; ++i) cin >> sx[i];
for(int i = 1; i <= m; ++i) cin >> a[i];
vector<int> v;
for(int i = 1; i <= m - n + 1; ++i){
int lst = 0;
bool flag = false;
for(int j = i; j < i + n; ++j){
int tmp = a[sx[j - i + 1] + i - 1];
if(tmp < lst){
flag = true;
break;
}
else lst = tmp;
}
if(!flag) v.pb(i);
}
cout << v.size() << endl;
for(int tmp : v){
cout << tmp << " ";
}
cout << endl;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//freopen(taskname".inp", "r", stdin);
//freopen(taskname".out", "w", stdout);
int t = 1; //cin >> t;
while(t--) solve();
}
# | 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... |