This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <cassert>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <stack>
#include <chrono>
#include <cstring>
#include <numeric>
using namespace std;
void print(vector<int> v) {
cout << " ---> ";
for (auto& x : v) {
cout << x << " ";
}
cout << "\n";
}
signed main() {
#ifdef ONPC
FILE* stream;
freopen_s(&stream, "input.txt", "r", stdin);
#else
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
#endif
int n, m;
cin >> n >> m;
vector<int> pattern(n), txt(m);
for (int i = 0; i < n; i++) {
int foo;
cin >> foo;
foo--;
assert(0 <= foo && foo < n);
pattern[foo] = i;
}
for (int i = 0; i < m; i++) {
cin >> txt[i];
}
vector<int> sols;
for (int i = 0; i + n - 1 < m; i++) {
vector<int> vec(txt.begin() + i, txt.begin() + i + n);
// normalize "vec"
map<int, int> T;
for (auto& x : vec) {
T[x] = 0;
}
int y = 0;
for (auto& it : T) {
it.second = y++;
}
for (auto& x : vec) {
x = T[x];
}
if (vec == pattern) {
sols.push_back(i);
}
}
cout << (int)sols.size() << "\n";
for (auto& i : sols) {
cout << i + 1 << " ";
}
cout << "\n";
return 0;
}
# | 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... |