Submission #848606

#TimeUsernameProblemLanguageResultExecution timeMemory
848606Essa2006Matching (CEOI11_mat)C++14
0 / 100
353 ms13108 KiB
#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)(1000000007) #define mod2 (ll)(32452867) 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 mul2(ll a, ll b){ a%=mod2, b%=mod2; return (a*b)%mod2; } int add2(int a, int b){ a%=mod2, b%=mod2; return (((a+b)%mod2)+mod2)%mod2; } int pw2(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], Val2[m]; int val=0, val2=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)); if(mp[A[i]-1]) val2=add2(val2, pw2(2, A[i]-1)); } for(int j=0;j<m;j++){ cin>>B[j]; } int cur=0, cur2=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))); cur2=add2(cur, pw2(2, n-1-(m-1-j))); } } for(int j=m-n;j>=0;j--){ Val[j]=cur; Val2[j]=cur2; if(!j) break; if(B[j+n-1]>B[j+n-2]){ cur=add(cur, -pw(2, n-1)); cur2=add2(cur2, -pw2(2, n-1)); } cur=mul(cur, 2); cur2=mul2(cur2, 2); if(B[j]>B[j-1]){ cur=add(cur, pw(2, 1)); cur2=add2(cur2, pw2(2, 1)); } } vector<int>Ans; for(int j=0;j<m;j++){ if(Val[j]==val && Val2[j]==val2) 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:178:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  178 |     for(int i=0;i<Ans.size();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...