Submission #1086853

#TimeUsernameProblemLanguageResultExecution timeMemory
1086853RiverFlowSorting (IOI15_sorting)C++14
20 / 100
1 ms436 KiB
//#include "sorting.h" #include <bits/stdc++.h> #define nl "\n" #define no "NO" #define yes "YES" #define fi first #define se second #define vec vector #define task "main" #define _mp make_pair #define ii pair<int, int> #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define evoid(val) return void(std::cout << val) #define FOR(i, a, b) for(int i = (a); i <= (b); ++i) #define FOD(i, b, a) for(int i = (b); i >= (a); --i) #define unq(x) sort(all(x)); x.resize(unique(all(x)) - x.begin()) using namespace std; int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[]) { p[0] = q[0] = 0; bool sub1 = 1, sub2 = 1; FOR(i, 0, m - 1) { sub1 &= max(x[i], y[i]) == 0; sub2 &= (x[i] == 0 and y[i] == 1); } int ans = 0; if (sub1) { FOD(i, n - 1, 0) if (s[i] != i) { FOD(j, i - 1, 0) if (s[j] == i) { p[ans] = i, q[ans] = j; ++ans; swap(s[i], s[j]); break ; } } return ans; } if (sub2) { FOD(i, n - 1, 2) if (s[i] != i) { FOD(j, i - 1, 0) if (s[j] == i) { p[ans] = i, q[ans] = j; ++ans; swap(s[i], s[j]); break ; } } if (ans & 1) swap(s[0], s[1]); if (s[0] == 1) { p[ans] = 0, q[ans] = 1; ++ans; } return ans; } return 1; }
#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...