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