Submission #632971

#TimeUsernameProblemLanguageResultExecution timeMemory
632971gagik_2007Xor Sort (eJOI20_xorsort)C++17
0 / 100
1 ms304 KiB
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <cmath> #include <ctime> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <limits> #include <iomanip> #include <unordered_set> #include <unordered_map> #include <fstream> #include <random> using namespace std; typedef long long ll; typedef double ld; typedef ll itn; #define ff first #define ss second ll ttt; const ll INF = 1e18; const ll SAFEINF = 1e12; const ll MOD = 1e9 + 7; const ll MOD2 = 998244353; const ll MOD3 = 32768; const ll N = 100007; ll n, m, k; ll a[1007]; vector<pair<int, int>>d; void poxi(int i, int j) { d.push_back({ i,j }); d.push_back({ j,i }); d.push_back({ i,j }); swap(a[i], a[j]); } int main() { cin >> n >> m; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = n - 1; i >= 0; i--) { for (int j = 0; j < i; j++) { if (a[j] > a[j + 1])poxi(j, j + 1); } } cout << d.size() << endl; for (auto x : d) { cout << x.ff << " " << x.ss << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...