diff --git a/S2OJ/1505/1505.cpp b/S2OJ/1505/1505.cpp new file mode 100644 index 00000000..1551758d --- /dev/null +++ b/S2OJ/1505/1505.cpp @@ -0,0 +1,56 @@ +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 100005; + +int n, m, q, d_a[N], d_b[N]; +bool a[N], b[N]; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n >> m; + + for (int i = 1; i <= n; i++) { + cin >> a[i]; + } + + for (int i = 1; i <= m; i++) { + cin >> b[i]; + } + + if (a[1] != a[n]) d_a[0] = 1; + for (int i = 1; i <= n; i++) { + d_a[i] = d_a[i - 1] + (a[i] != a[i + 1]); + } + + if (b[1] != b[m]) d_b[0] = 1; + for (int i = 1; i <= m; i++) { + d_b[i] = d_b[i - 1] + (b[i] != b[i + 1]); + } + + cin >> q; + + while (q--) { + std::pair s, e; + + cin >> s.first >> s.second >> e.first >> e.second; + + cout << std::min({ + std::abs(d_a[s.first - 1] - d_a[e.first - 1]), + d_a[n - 1] - d_a[std::max(s.first, e.first) - 1] + d_a[std::min(s.first, e.first) - 1], + }) + std::min({ + std::abs(d_b[s.second - 1] - d_b[e.second - 1]), + d_b[m - 1] - d_b[std::max(s.second, e.second) - 1] + d_b[std::min(s.second, e.second) - 1], + }) + << endl; + } + + return 0; +} diff --git a/S2OJ/1505/data/data1.in b/S2OJ/1505/data/data1.in new file mode 100644 index 00000000..4f14dce1 --- /dev/null +++ b/S2OJ/1505/data/data1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d219e08873346bfa93472f6281b31e539a5e51bef3a5cf48840c419c1a03ab48 +size 532 diff --git a/S2OJ/1505/data/data1.out b/S2OJ/1505/data/data1.out new file mode 100644 index 00000000..be52f68a --- /dev/null +++ b/S2OJ/1505/data/data1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4b76271dc7983e15d65d906e1df4f4f75fb719ac272077c4e31ead68f502c5b +size 29 diff --git a/S2OJ/1505/data/data10.in b/S2OJ/1505/data/data10.in new file mode 100644 index 00000000..7635a477 --- /dev/null +++ b/S2OJ/1505/data/data10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a6b366379af20cfffde2d8b8c692eb5c6f9e30f835cc51d8891493d648ad25a +size 2755706 diff --git a/S2OJ/1505/data/data10.out b/S2OJ/1505/data/data10.out new file mode 100644 index 00000000..9c15cb1e --- /dev/null +++ b/S2OJ/1505/data/data10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f66b77ad7c8283ddda33bcdf21b7470af5b67de23798114ad0b4e8c3fe075f46 +size 591780 diff --git a/S2OJ/1505/data/data2.in b/S2OJ/1505/data/data2.in new file mode 100644 index 00000000..7a83b620 --- /dev/null +++ b/S2OJ/1505/data/data2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ff924f3d7f7d5f7ad1cbb86b54b2fc96d94623a0b98641bcb36a01c4ac9f78e7 +size 2755296 diff --git a/S2OJ/1505/data/data2.out b/S2OJ/1505/data/data2.out new file mode 100644 index 00000000..43a87c8f --- /dev/null +++ b/S2OJ/1505/data/data2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:365ad96e87eab5b641d668ba53fbbcf3f2b837f331dcc66a07afbc7a36e5ad9b +size 591961 diff --git a/S2OJ/1505/data/data3.in b/S2OJ/1505/data/data3.in new file mode 100644 index 00000000..f4afda4b --- /dev/null +++ b/S2OJ/1505/data/data3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0ceba6f1cdfa15f498518f10c870c2af4392fc2442607af6485ca3481908041a +size 2755604 diff --git a/S2OJ/1505/data/data3.out b/S2OJ/1505/data/data3.out new file mode 100644 index 00000000..7cf9048f --- /dev/null +++ b/S2OJ/1505/data/data3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7c70e3f700b5465726ec45c5fea1eb5e9c48c72fcb10d83a215285ffbb042e6f +size 591995 diff --git a/S2OJ/1505/data/data4.in b/S2OJ/1505/data/data4.in new file mode 100644 index 00000000..d7bd581b --- /dev/null +++ b/S2OJ/1505/data/data4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ce5550f169ad4ea6fc0232a25d4628d1fff09af165324f7e41ba6c42bdf5a6dc +size 529 diff --git a/S2OJ/1505/data/data4.out b/S2OJ/1505/data/data4.out new file mode 100644 index 00000000..785177d3 --- /dev/null +++ b/S2OJ/1505/data/data4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9daf6b9c5958f2a095d387ac9dc338032e7da5274228a8decb653fd794ca607b +size 29 diff --git a/S2OJ/1505/data/data5.in b/S2OJ/1505/data/data5.in new file mode 100644 index 00000000..42734ed0 --- /dev/null +++ b/S2OJ/1505/data/data5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d533ccaf8b8364b1abeddc45be4060eb9b105f41ac79b6dce575f7ff63d7528b +size 532 diff --git a/S2OJ/1505/data/data5.out b/S2OJ/1505/data/data5.out new file mode 100644 index 00000000..236d1af4 --- /dev/null +++ b/S2OJ/1505/data/data5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:955e22a07fb34db60737655bdde3433d848a1d14dc8684508d8d57b32697d3dd +size 29 diff --git a/S2OJ/1505/data/data6.in b/S2OJ/1505/data/data6.in new file mode 100644 index 00000000..43141e94 --- /dev/null +++ b/S2OJ/1505/data/data6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:554e753f1127f2b4f1dba703be9c13d5f845ec14afb6eaddac62bf2b3c9d9458 +size 1777829 diff --git a/S2OJ/1505/data/data6.out b/S2OJ/1505/data/data6.out new file mode 100644 index 00000000..f7940491 --- /dev/null +++ b/S2OJ/1505/data/data6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33cbb99ac15ec58cff4e9e8c68196a6d486e0a77067793b89f194e5c81f2a7eb +size 555422 diff --git a/S2OJ/1505/data/data7.in b/S2OJ/1505/data/data7.in new file mode 100644 index 00000000..83bfc5b5 --- /dev/null +++ b/S2OJ/1505/data/data7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:11dbe4068f51f5c5975e1d65424f220c126e05adc2e12433171e9e07b4257513 +size 1777865 diff --git a/S2OJ/1505/data/data7.out b/S2OJ/1505/data/data7.out new file mode 100644 index 00000000..10e9756f --- /dev/null +++ b/S2OJ/1505/data/data7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:52477c0ee0c726f0638f4112c6bab01b6522bf219f98fd5a63e83e4a96c404df +size 555233 diff --git a/S2OJ/1505/data/data8.in b/S2OJ/1505/data/data8.in new file mode 100644 index 00000000..db9a027c --- /dev/null +++ b/S2OJ/1505/data/data8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa8736ededd7ea82975a4eb3a0855e77d11fe3ef4a0564833a84a4c3ef171642 +size 2756098 diff --git a/S2OJ/1505/data/data8.out b/S2OJ/1505/data/data8.out new file mode 100644 index 00000000..29d634d8 --- /dev/null +++ b/S2OJ/1505/data/data8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f2ca93ae49b900b43c732e66ad59aefe97a2a8225ab664f54abb035e2d5a13f +size 591955 diff --git a/S2OJ/1505/data/data9.in b/S2OJ/1505/data/data9.in new file mode 100644 index 00000000..635b1764 --- /dev/null +++ b/S2OJ/1505/data/data9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8ac97c53e85ab9d92d6d513e54533f6c0ab079315a855e23632427ee4d673556 +size 2755634 diff --git a/S2OJ/1505/data/data9.out b/S2OJ/1505/data/data9.out new file mode 100644 index 00000000..5e65d64a --- /dev/null +++ b/S2OJ/1505/data/data9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6db9785394b87cb589673566ac9cb286c0a1d12038a48ac1619764a0fdde8f13 +size 591936 diff --git a/S2OJ/1505/data/problem.conf b/S2OJ/1505/data/problem.conf new file mode 100644 index 00000000..a39aada8 --- /dev/null +++ b/S2OJ/1505/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:16c8474d800be5daf3cb0f74c8aa06133e1bf6d3bb8df5be994e363d2ab648b7 +size 177