# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1041982 | 2024-08-02T11:38:11 Z | c2zi6 | Sorting (IOI15_sorting) | C++14 | 1000 ms | 804 KB |
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<typename T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "sorting.h" #define ANSWER {\ rep(i, ans.size()) {\ P[i] = ans[i].ff;\ Q[i] = ans[i].ss;\ }\ return ans.size();\ } struct PERM { int n; VI a; VI ind; PERM(int N_ARG) : n(N_ARG) { a = ind = VI(n); rep(i, n) a[i] = ind[i] = i; } PERM(VI A_ARG) : a(A_ARG) { n = a.size(); ind = VI(n); rep(i, n) ind[a[i]] = i; } int size() { return n; } int& operator[](const int i) { return a[i]; } }; PERM operator*(const PERM& perm, const PII p) { auto[x, y] = p; PERM ret = perm; swap(ret.ind[ret[x]], ret.ind[ret[y]]); swap(ret[x], ret[y]); return ret; } void operator*=(PERM& perm, const PII p) { perm = perm * p; } VPI ans; bool f(const VI& A_ARG, const VPI& op) { PERM a(A_ARG); int n = a.size(); int m = op.size(); PERM cur(n); reprl(i, m-1, 0) cur *= op[i]; VPI ret; int i = 0; for (const PII& p : op) { cur *= p; a *= p; while (i < n && a.ind[i] == cur.ind[i]) i++; int x, y; if (i == n) { x = y = 0; } else { x = a.ind[i]; y = cur.ind[i]; } ans.pb({x, y}); a *= mkp(x, y); } rep(i, n) if (a[i] != i) return false; return true; } int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { int n = N; int m = M; VI a(n); rep(i, n) a[i] = S[i]; VPI op(m); rep(i, M) op[i] = mkp(X[i], Y[i]); VPI curop; rep(i, m+1) { /*cout << "KPORDZENQ " << i << " HATOV" << endl;*/ ans.clear(); if (f(a, curop)) { ANSWER } if (i == m) break; curop.pb(op[i]); } for (int r = 0;; r++) { } ANSWER; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 448 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 448 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 344 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 41 ms | 804 KB | Output is correct |
22 | Correct | 39 ms | 604 KB | Output is correct |
23 | Correct | 49 ms | 796 KB | Output is correct |
24 | Correct | 33 ms | 600 KB | Output is correct |
25 | Correct | 5 ms | 600 KB | Output is correct |
26 | Correct | 15 ms | 788 KB | Output is correct |
27 | Correct | 38 ms | 796 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1037 ms | 596 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1037 ms | 596 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |