이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb push_back
#define mpr make_pair
#define lb lower_bound
#define ld long double
#define ub upper_bound
map<pair<int, int>, bool> m;
int n, s;
int a[100005];
void solve() {
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<pair<int, int> > ans;
    for (int i = 0; i < n - 1; i++) {
        for (int j = 0; j < n - i - 1; j++) {
            if (a[j] > a[j + 1]) {
                ans.push_back(mpr(j + 1, j + 2));
                ans.push_back(mpr(j + 2, j + 1));
                ans.push_back(mpr(j + 1, j + 2));
                swap(a[j], a[j + 1]);
            }
        }
    }
    cout << ans.size() << endl;
    for (auto i : ans) {
        cout << i.first << ' ' << i.second << endl;
    }
}
int main() {
    /*cout.setf(ios::fixed | ios::showpoint);
    cout.precision(6);*/
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |