diff --git a/S2OJ/1550/1550.cpp b/S2OJ/1550/1550.cpp new file mode 100644 index 00000000..fa71ea51 --- /dev/null +++ b/S2OJ/1550/1550.cpp @@ -0,0 +1,38 @@ +#include +#include + +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(n) * (n - 1) + ans - flag << endl; + + return 0; +} diff --git a/S2OJ/1550/data/bubble1.ans b/S2OJ/1550/data/bubble1.ans new file mode 100644 index 00000000..38118f32 --- /dev/null +++ b/S2OJ/1550/data/bubble1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53c234e5e8472b6ac51c1ae1cab3fe06fad053beb8ebfd8977b010655bfdd3c3 +size 2 diff --git a/S2OJ/1550/data/bubble1.in b/S2OJ/1550/data/bubble1.in new file mode 100644 index 00000000..8e8c02ad --- /dev/null +++ b/S2OJ/1550/data/bubble1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fdcb27265764b2a73c62380d364aa177b18028a2d6fffe621bac5a23affde265 +size 6 diff --git a/S2OJ/1550/data/bubble10.ans b/S2OJ/1550/data/bubble10.ans new file mode 100644 index 00000000..d4e96fee --- /dev/null +++ b/S2OJ/1550/data/bubble10.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:baf9dc30802f6ba0bb5f9ece28ff983ab96673264462baa05bf7ea746bcb28f3 +size 11 diff --git a/S2OJ/1550/data/bubble10.in b/S2OJ/1550/data/bubble10.in new file mode 100644 index 00000000..195000f0 --- /dev/null +++ b/S2OJ/1550/data/bubble10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3a05492926eb83d7b49d509ebc7d02054ecf6fc56e4d2bb23f634a1ba8ecc30d +size 588902 diff --git a/S2OJ/1550/data/bubble2.ans b/S2OJ/1550/data/bubble2.ans new file mode 100644 index 00000000..8da2bb0d --- /dev/null +++ b/S2OJ/1550/data/bubble2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f4ccd05b3271c386ee55d9876c7450012a3b361e5065c09dc22075e38b3cc35c +size 3 diff --git a/S2OJ/1550/data/bubble2.in b/S2OJ/1550/data/bubble2.in new file mode 100644 index 00000000..3bbba933 --- /dev/null +++ b/S2OJ/1550/data/bubble2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ddb7eb9d33fde5faa1a687a0e10ec4ca63a78e97881633b7ad480e3affdaec6 +size 14 diff --git a/S2OJ/1550/data/bubble3.ans b/S2OJ/1550/data/bubble3.ans new file mode 100644 index 00000000..ce22562b --- /dev/null +++ b/S2OJ/1550/data/bubble3.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:969eeff1eaac226a228cc61503effa46ea87d872ef3174365befc7c36ffa3c48 +size 3 diff --git a/S2OJ/1550/data/bubble3.in b/S2OJ/1550/data/bubble3.in new file mode 100644 index 00000000..5ae1d504 --- /dev/null +++ b/S2OJ/1550/data/bubble3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15f7869bc231ee00996280a1e64515ed508591824317ee1ed508d718b823cc24 +size 24 diff --git a/S2OJ/1550/data/bubble4.ans b/S2OJ/1550/data/bubble4.ans new file mode 100644 index 00000000..b3c252c9 --- /dev/null +++ b/S2OJ/1550/data/bubble4.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:367a8bd2c45fdf424137779e401d8c8ba5964a8daf09d8424a7529bc3b1e269e +size 7 diff --git a/S2OJ/1550/data/bubble4.in b/S2OJ/1550/data/bubble4.in new file mode 100644 index 00000000..96038cbf --- /dev/null +++ b/S2OJ/1550/data/bubble4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:185c38375c216ec1b9c676804a6353632fc901e916b324d57ca64fdf1ca83119 +size 1228 diff --git a/S2OJ/1550/data/bubble5.ans b/S2OJ/1550/data/bubble5.ans new file mode 100644 index 00000000..b39ea21d --- /dev/null +++ b/S2OJ/1550/data/bubble5.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:acb18536629e8c69f7c8bda33dc9893bd02c6574616c3eb7ac0ef08715e39cf2 +size 7 diff --git a/S2OJ/1550/data/bubble5.in b/S2OJ/1550/data/bubble5.in new file mode 100644 index 00000000..4ca98772 --- /dev/null +++ b/S2OJ/1550/data/bubble5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:336c3b8aa50a0643bc4c1503c8ddceeb65813df7e424b5c886c74f8d34e2b0e7 +size 1672 diff --git a/S2OJ/1550/data/bubble6.ans b/S2OJ/1550/data/bubble6.ans new file mode 100644 index 00000000..8041605f --- /dev/null +++ b/S2OJ/1550/data/bubble6.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:200ce3556b885ba87660b226d37506af92cdb655a4365c343aa980cf3e2b77b4 +size 7 diff --git a/S2OJ/1550/data/bubble6.in b/S2OJ/1550/data/bubble6.in new file mode 100644 index 00000000..19d23cb3 --- /dev/null +++ b/S2OJ/1550/data/bubble6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:617ac17ef6da82f71794d7bbf143d328146a07b37e7e787025eb375ffcf06428 +size 2116 diff --git a/S2OJ/1550/data/bubble7.ans b/S2OJ/1550/data/bubble7.ans new file mode 100644 index 00000000..39228413 --- /dev/null +++ b/S2OJ/1550/data/bubble7.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:579898d12f42e933710dc8cb40cfb892df28b4f2682bc1bee238324ee67879ad +size 11 diff --git a/S2OJ/1550/data/bubble7.in b/S2OJ/1550/data/bubble7.in new file mode 100644 index 00000000..ee4064e6 --- /dev/null +++ b/S2OJ/1550/data/bubble7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d5c02eb7a5bdba2399ed15a3293a0210db16e5b82f44a87e8c2c3ab958126c28 +size 455562 diff --git a/S2OJ/1550/data/bubble8.ans b/S2OJ/1550/data/bubble8.ans new file mode 100644 index 00000000..df1180c0 --- /dev/null +++ b/S2OJ/1550/data/bubble8.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:86ef898014fd9457a6aa4327bf7856601fc64e0578dbb77be35f9c416ed105af +size 11 diff --git a/S2OJ/1550/data/bubble8.in b/S2OJ/1550/data/bubble8.in new file mode 100644 index 00000000..34e4172e --- /dev/null +++ b/S2OJ/1550/data/bubble8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:65e2ea4e4c5a010434686e2d5a9ef08cfd1843b1c7c2eadccfaf51f635c509c2 +size 522228 diff --git a/S2OJ/1550/data/bubble9.ans b/S2OJ/1550/data/bubble9.ans new file mode 100644 index 00000000..c13c8fcd --- /dev/null +++ b/S2OJ/1550/data/bubble9.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a72093e7f858f563a7d4979954a2c4b316381813257d1559050d5fb0bb22ca4f +size 11 diff --git a/S2OJ/1550/data/bubble9.in b/S2OJ/1550/data/bubble9.in new file mode 100644 index 00000000..f98f8265 --- /dev/null +++ b/S2OJ/1550/data/bubble9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:13ab3ff67760939236189939fc9946a646f5f7edb27de8a675f619c163658e9f +size 588894 diff --git a/S2OJ/1550/data/problem.conf b/S2OJ/1550/data/problem.conf new file mode 100644 index 00000000..1445101a --- /dev/null +++ b/S2OJ/1550/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2604bf54d5938e164b0885d96b07cff9c2d239b800c4fdba228bd3ba1f93c3a +size 181