Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Problem: B - Triple Shift
- // Contest: AtCoder - AtCoder Regular Contest 136
- // URL: https://atcoder.jp/contests/arc136/tasks/arc136_b
- // Memory Limit: 1024 MB
- // Time Limit: 2000 ms
- //
- // Powered by CP Editor (https://cpeditor.org)
- #include <assert.h>
- #include <bits/stdc++.h>
- using namespace std;
- #define dbg(...) logger(#__VA_ARGS__, __VA_ARGS__)
- template <typename... Args> void logger(string vars, Args &&... values)
- {
- cerr << vars << " = ";
- string delim = "";
- (..., (cerr << delim << values, delim = ", "));
- cerr << endl;
- }
- template <class T> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m)); }
- template <class T> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n)); }
- template <class T, T init> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m, init)); }
- template <class T, T init> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n, init)); }
- template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
- using vi = vector<int>;
- using ll = long long;
- using pii = pair<int, int>;
- int main(int argc, char **argv)
- {
- int n;
- cin >> n;
- vi a(n), b(n);
- map<int, int> ma, mb;
- for (int i = 0; i < n; ++i)
- cin >> a[i], ma[a[i]]++;
- for (int i = 0; i < n; ++i)
- cin >> b[i], mb[b[i]]++;
- if (ma != mb) {
- cout << "No" << endl;
- return 0;
- }
- int inva = 0, invb = 0;
- for (int i = 0; i < n; ++i)
- for (int j = i + 1; j < n; ++j) {
- if (a[i] > a[j])
- inva++;
- if (b[i] > b[j])
- invb++;
- }
- int duplicate = 0;
- for (auto p : ma) {
- if (p.second > 1)
- duplicate = 1;
- }
- cout << (duplicate == 1 || inva % 2 == invb % 2 ? "Yes" : "No") << endl;
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement