0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 19:08:47 +00:00

#1550. 【2022.09.11 NOIP 模拟】假冒泡排序

https://sjzezoj.com/submission/56272
This commit is contained in:
Baoshuo Ren 2022-09-11 15:15:45 +08:00
parent d8e347f8ab
commit b5d6d5a0fc
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
22 changed files with 101 additions and 0 deletions

38
S2OJ/1550/1550.cpp Normal file
View File

@ -0,0 +1,38 @@
#include <iostream>
#include <algorithm>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e5 + 5;
int n, a[N], c[N], p, ans;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
bool flag = n >= 3;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (a[i] == n) p = i;
}
flag &= a[1] == n - 1 && a[n] == n;
for (int i = 1; i < p; i++) {
if (a[i] > a[i + 1]) {
ans++;
std::swap(a[i], a[i + 1]);
}
}
cout << static_cast<long long>(n) * (n - 1) + ans - flag << endl;
return 0;
}

BIN
S2OJ/1550/data/bubble1.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble10.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble3.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble4.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble5.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble6.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble7.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble8.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble9.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/bubble9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1550/data/problem.conf (Stored with Git LFS) Normal file

Binary file not shown.