From 94feba5a445e7e9fb4d6cf33bcd1c5eb917fd15b Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 6 Jun 2022 16:03:39 +0800 Subject: [PATCH] =?UTF-8?q?#2108.=20=E3=80=8CJLOI2015=E3=80=8D=E8=A3=85?= =?UTF-8?q?=E5=A4=87=E8=B4=AD=E4=B9=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://loj.ac/s/1476841 --- LibreOJ/2108/2108.cpp | 76 ++++++++++++++++++++++++++++++++ LibreOJ/2108/data/purchase1.in | 3 ++ LibreOJ/2108/data/purchase1.out | 3 ++ LibreOJ/2108/data/purchase10.in | 3 ++ LibreOJ/2108/data/purchase10.out | 3 ++ LibreOJ/2108/data/purchase2.in | 3 ++ LibreOJ/2108/data/purchase2.out | 3 ++ LibreOJ/2108/data/purchase3.in | 3 ++ LibreOJ/2108/data/purchase3.out | 3 ++ LibreOJ/2108/data/purchase4.in | 3 ++ LibreOJ/2108/data/purchase4.out | 3 ++ LibreOJ/2108/data/purchase5.in | 3 ++ LibreOJ/2108/data/purchase5.out | 3 ++ LibreOJ/2108/data/purchase6.in | 3 ++ LibreOJ/2108/data/purchase6.out | 3 ++ LibreOJ/2108/data/purchase7.in | 3 ++ LibreOJ/2108/data/purchase7.out | 3 ++ LibreOJ/2108/data/purchase8.in | 3 ++ LibreOJ/2108/data/purchase8.out | 3 ++ LibreOJ/2108/data/purchase9.in | 3 ++ LibreOJ/2108/data/purchase9.out | 3 ++ 21 files changed, 136 insertions(+) create mode 100644 LibreOJ/2108/2108.cpp create mode 100644 LibreOJ/2108/data/purchase1.in create mode 100644 LibreOJ/2108/data/purchase1.out create mode 100644 LibreOJ/2108/data/purchase10.in create mode 100644 LibreOJ/2108/data/purchase10.out create mode 100644 LibreOJ/2108/data/purchase2.in create mode 100644 LibreOJ/2108/data/purchase2.out create mode 100644 LibreOJ/2108/data/purchase3.in create mode 100644 LibreOJ/2108/data/purchase3.out create mode 100644 LibreOJ/2108/data/purchase4.in create mode 100644 LibreOJ/2108/data/purchase4.out create mode 100644 LibreOJ/2108/data/purchase5.in create mode 100644 LibreOJ/2108/data/purchase5.out create mode 100644 LibreOJ/2108/data/purchase6.in create mode 100644 LibreOJ/2108/data/purchase6.out create mode 100644 LibreOJ/2108/data/purchase7.in create mode 100644 LibreOJ/2108/data/purchase7.out create mode 100644 LibreOJ/2108/data/purchase8.in create mode 100644 LibreOJ/2108/data/purchase8.out create mode 100644 LibreOJ/2108/data/purchase9.in create mode 100644 LibreOJ/2108/data/purchase9.out diff --git a/LibreOJ/2108/2108.cpp b/LibreOJ/2108/2108.cpp new file mode 100644 index 00000000..2596f854 --- /dev/null +++ b/LibreOJ/2108/2108.cpp @@ -0,0 +1,76 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 505; +const double eps = 1e-4; + +int n, m, ans, sum; +double p[N][N]; + +struct node { + int w; + double v[N]; + + double& operator[](const int& _i) { + return v[_i]; + } + + bool operator<(const node& _y) const { + return w < _y.w; + } +} q[N]; + +inline bool insert(double* a) { + for (int i = 1; i <= m; i++) { + if (std::abs(a[i]) > eps) { + if (std::abs(p[i][i]) > eps) { // > 0 + double k = a[i] / p[i][i]; + for (int j = i; j <= m; j++) { + a[j] -= k * p[i][j]; + } + } else { + for (int j = i; j <= m; j++) { + p[i][j] = a[j]; + } + + return true; + } + } + } + + return false; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n >> m; + + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= m; j++) { + cin >> q[i][j]; + } + } + + for (int i = 1; i <= n; i++) { + cin >> q[i].w; + } + + std::sort(q + 1, q + 1 + n); + + for (int i = 1; i <= n; i++) { + if (insert(q[i].v)) { + ans++; + sum += q[i].w; + } + } + + cout << ans << ' ' << sum << endl; + + return 0; +} diff --git a/LibreOJ/2108/data/purchase1.in b/LibreOJ/2108/data/purchase1.in new file mode 100644 index 00000000..ef6837c7 --- /dev/null +++ b/LibreOJ/2108/data/purchase1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa35af6260f3903a6772ffb25a857c84325efd7fa2b3efd261b1dfa3e972374e +size 247 diff --git a/LibreOJ/2108/data/purchase1.out b/LibreOJ/2108/data/purchase1.out new file mode 100644 index 00000000..5b9ff62a --- /dev/null +++ b/LibreOJ/2108/data/purchase1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:be8cbbda669784f26cee5fb6304858b03e84083b7b9f71af83e18d842926ab13 +size 7 diff --git a/LibreOJ/2108/data/purchase10.in b/LibreOJ/2108/data/purchase10.in new file mode 100644 index 00000000..5dc0dbaf --- /dev/null +++ b/LibreOJ/2108/data/purchase10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b89d8a5d98a6f168d80ac0b46e3dc08f75aca75717e5e241c2828cf8544abdec +size 1047747 diff --git a/LibreOJ/2108/data/purchase10.out b/LibreOJ/2108/data/purchase10.out new file mode 100644 index 00000000..67fc654e --- /dev/null +++ b/LibreOJ/2108/data/purchase10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f7b2d4ecf9a4ffd9a28266319d0de9cbd424096f6cdb44e92c306ba027a681e2 +size 12 diff --git a/LibreOJ/2108/data/purchase2.in b/LibreOJ/2108/data/purchase2.in new file mode 100644 index 00000000..029a88c0 --- /dev/null +++ b/LibreOJ/2108/data/purchase2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd12ae608076972b1deb5943d30ef2e8fbe74308f107ee0d5d8ba23badba8942 +size 642 diff --git a/LibreOJ/2108/data/purchase2.out b/LibreOJ/2108/data/purchase2.out new file mode 100644 index 00000000..e4ed6b10 --- /dev/null +++ b/LibreOJ/2108/data/purchase2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4af616494aa89131d6a9081a49b0b903c6a072be62b1799c7bb3bd384ee6ac9e +size 9 diff --git a/LibreOJ/2108/data/purchase3.in b/LibreOJ/2108/data/purchase3.in new file mode 100644 index 00000000..86b731a3 --- /dev/null +++ b/LibreOJ/2108/data/purchase3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e12597a1c7f829053e7dc3cc0ed223ae8b7173459685bc89f6a0c64d3e9460c2 +size 646 diff --git a/LibreOJ/2108/data/purchase3.out b/LibreOJ/2108/data/purchase3.out new file mode 100644 index 00000000..43fed09d --- /dev/null +++ b/LibreOJ/2108/data/purchase3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9cdc4674228742a59e4de1c7abb946cbaa4086873a39e1b883b00a0eafa684e8 +size 10 diff --git a/LibreOJ/2108/data/purchase4.in b/LibreOJ/2108/data/purchase4.in new file mode 100644 index 00000000..3ca2a240 --- /dev/null +++ b/LibreOJ/2108/data/purchase4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b6ac58f48b48676090c6cdc150552bc54404db3f93ef37b5b0418856282ead42 +size 629 diff --git a/LibreOJ/2108/data/purchase4.out b/LibreOJ/2108/data/purchase4.out new file mode 100644 index 00000000..40759941 --- /dev/null +++ b/LibreOJ/2108/data/purchase4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:38928f39c024c00062e32ea6f4e94d008b060b44018e40ee5ccea299e8c581bb +size 10 diff --git a/LibreOJ/2108/data/purchase5.in b/LibreOJ/2108/data/purchase5.in new file mode 100644 index 00000000..c96fcec1 --- /dev/null +++ b/LibreOJ/2108/data/purchase5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1f3823d41b1be9426725ca5f4e1698cf630584471d6ee1ddb7dabd5931f15316 +size 1172 diff --git a/LibreOJ/2108/data/purchase5.out b/LibreOJ/2108/data/purchase5.out new file mode 100644 index 00000000..500ef30c --- /dev/null +++ b/LibreOJ/2108/data/purchase5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa8a136a98e3650b4fc541b6e4d0981af3ac345030dd0bbb3bbafa213a148792 +size 9 diff --git a/LibreOJ/2108/data/purchase6.in b/LibreOJ/2108/data/purchase6.in new file mode 100644 index 00000000..4ac3b071 --- /dev/null +++ b/LibreOJ/2108/data/purchase6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6c09ed38ee5d0a98cf179d7f3b565d00633c5cbaa6f71dc58a8a3418afc02128 +size 41708 diff --git a/LibreOJ/2108/data/purchase6.out b/LibreOJ/2108/data/purchase6.out new file mode 100644 index 00000000..6b8b716a --- /dev/null +++ b/LibreOJ/2108/data/purchase6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:876f87773f9c7e77e2a42a2ad8c7c57abe6958b995269b883b64642972e77b15 +size 10 diff --git a/LibreOJ/2108/data/purchase7.in b/LibreOJ/2108/data/purchase7.in new file mode 100644 index 00000000..ffb37053 --- /dev/null +++ b/LibreOJ/2108/data/purchase7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8472ed1ef12aa30b3cdddbbbb8eba7263f6332bad2da66e86c9b4ffdca360e57 +size 42115 diff --git a/LibreOJ/2108/data/purchase7.out b/LibreOJ/2108/data/purchase7.out new file mode 100644 index 00000000..48677d8f --- /dev/null +++ b/LibreOJ/2108/data/purchase7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3bc6f6e469a9cf8e8c9c8e70f685651286706896f63906f6a7deb967700ac362 +size 10 diff --git a/LibreOJ/2108/data/purchase8.in b/LibreOJ/2108/data/purchase8.in new file mode 100644 index 00000000..2d6bbb7c --- /dev/null +++ b/LibreOJ/2108/data/purchase8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04a3de8acc67530a209d5a9aca54eaf3d2aedb23935430b30f54f0a7bf95743e +size 1046859 diff --git a/LibreOJ/2108/data/purchase8.out b/LibreOJ/2108/data/purchase8.out new file mode 100644 index 00000000..c8fc0447 --- /dev/null +++ b/LibreOJ/2108/data/purchase8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ccb7c5f95cd5a2e00125a6f954dec9d9372dcbd67c5e3ab6f26481d63c77fb3 +size 12 diff --git a/LibreOJ/2108/data/purchase9.in b/LibreOJ/2108/data/purchase9.in new file mode 100644 index 00000000..b912cec4 --- /dev/null +++ b/LibreOJ/2108/data/purchase9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:99e8b0a826691f7865940774b17689d8737f33a444398eebcf1abac76d887293 +size 1053129 diff --git a/LibreOJ/2108/data/purchase9.out b/LibreOJ/2108/data/purchase9.out new file mode 100644 index 00000000..f9930c00 --- /dev/null +++ b/LibreOJ/2108/data/purchase9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8263ce25b3191c02293c910fb5c3656f55d30e46905028d3ca1abad5d7e14c3e +size 12