Submission #1079284

#TimeUsernameProblemLanguageResultExecution timeMemory
1079284Mike_VuMatching (CEOI11_mat)C++14
0 / 100
2074 ms860 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double dou; #define pii pair<int, int> #define pb push_back #define fi first #define se second bool maximize(ll &x, ll y ){ if (x < y) {x = y; return true;}; return false; } bool minimize(ll &x, ll y){ if (x > y) {x = y; return true;} return false; } const int maxn = 20005; int n, m, s[maxn], a[maxn]; bool check(int id ){ --id; for (int i = id+2; i <= id+n+1; i++) { for (int j = id+1; j < i; j++) { if ((s[i-id]<s[j-id]&&a[i]>a[j])||(s[i-id]>s[j-id]&&a[i]<a[j])) return 0; } } return 1; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { int x; cin >> x; s[x] = i; } for (int i = 1; i <= m ;i++) { cin >> a[i]; } vector<int> ans; for (int i = 1; i <= m; i++) { if (check(i)) ans.pb(i); } cout << ans.size() << "\n"; for (int x : ans) { cout << x << ' '; } }
#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...