이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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)
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;
}
컴파일 시 표준 에러 (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... |