This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define ll long long
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(34353637)
int mul(ll a, ll b){
a%=mod, b%=mod;
return (a*b)%mod;
}
int add(int a, int b){
a%=mod, b%=mod;
return (((a+b)%mod)+mod)%mod;
}
int pw(int a, int b){
int res=1;
while(b){
if(b&1)
res=mul(res, a);
a=mul(a, a), b/=2;
}
return res;
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n, m;
cin>>n>>m;
int A[n], B[m], Val[m];
int val=0;
vector<bool>mp(n+1);
for(int i=0;i<n;i++){
cin>>A[i];
mp[A[i]]=1;
if(mp[A[i]-1])
val=add(val, pw(2, A[i]-1));
}
for(int j=0;j<m;j++){
cin>>B[j];
}
int cur=0;
for(int j=m-1;j>=m-n+1;j--){
if(B[j]>B[j-1]){
cur=add(cur, pw(2, n-1-(m-1-j)));
}
}
for(int j=m-n;j>=0;j--){
Val[j]=cur;
if(!j)
break;
if(B[j+n-1]>B[j+n-2])
cur=add(cur, -pw(2, n-1));
cur=mul(cur, 2);
if(B[j]>B[j-1])
cur=add(cur, pw(2, 1));
}
vector<int>Ans;
for(int j=0;j+n-1<m;j++){
if(Val[j]==val)
Ans.push_back(j+1);
}
cout<<Ans.size()<<endl;
for(int i=0;i<Ans.size();i++){
cout<<Ans[i]<<' ';
}
cout<<endl;
}
Compilation message (stderr)
mat.cpp: In function 'int main()':
mat.cpp:150:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
150 | for(int i=0;i<Ans.size();i++){
| ~^~~~~~~~~~~
# | 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... |