diff --git a/S2OJ/974/974.cpp b/S2OJ/974/974.cpp new file mode 100644 index 00000000..1880555d --- /dev/null +++ b/S2OJ/974/974.cpp @@ -0,0 +1,60 @@ +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 5e5 + 5; + +int n, a[N], val, pre[N], suf[N]; +std::vector ans; +std::stack st_pre, st_suf; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n; + + for (int i = 1; i <= n; i++) { + cin >> a[i]; + } + + for (int i = 1; i <= n; i++) { + while (!st_pre.empty() && a[st_pre.top()] % a[i] == 0) st_pre.pop(); + pre[i] = i - (st_pre.empty() ? 0 : st_pre.top()) - 1; + st_pre.emplace(i); + } + + for (int i = n; i; i--) { + while (!st_suf.empty() && a[st_suf.top()] % a[i] == 0) st_suf.pop(); + suf[i] = (st_suf.empty() ? n + 1 : st_suf.top()) - i - 1; + st_suf.emplace(i); + } + + for (int i = 1; i <= n; i++) { + val = std::max(val, pre[i] + suf[i]); + } + + for (int i = 1; i <= n; i++) { + if (pre[i] + suf[i] == val) { + ans.emplace_back(i - pre[i]); + } + } + + std::sort(ans.begin(), ans.end()); + ans.erase(std::unique(ans.begin(), ans.end()), ans.end()); + + cout << ans.size() << ' ' << val << endl; + + for (int x : ans) { + cout << x << ' '; + } + + cout << endl; + + return 0; +} diff --git a/S2OJ/974/data/point1.in b/S2OJ/974/data/point1.in new file mode 100644 index 00000000..fe27a828 --- /dev/null +++ b/S2OJ/974/data/point1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:090e3600f0324013dc70a262c44810dcb189073414097f8ce0a218c7ec52d3d7 +size 83 diff --git a/S2OJ/974/data/point1.out b/S2OJ/974/data/point1.out new file mode 100644 index 00000000..c55f7f0d --- /dev/null +++ b/S2OJ/974/data/point1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6b01f3ca892e7e29b4d41ff63d80e490995e35eebb2ea48af9f575d07487a39 +size 7 diff --git a/S2OJ/974/data/point10.in b/S2OJ/974/data/point10.in new file mode 100644 index 00000000..af170459 --- /dev/null +++ b/S2OJ/974/data/point10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4e272dad05fbe5bb0e3f422ddf7983355e2013bb0fe0e08e6800e22deda2bf2e +size 9931 diff --git a/S2OJ/974/data/point10.out b/S2OJ/974/data/point10.out new file mode 100644 index 00000000..407758d6 --- /dev/null +++ b/S2OJ/974/data/point10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ba2bca2cf91c55365c6775a401d197b88cde9276bf274f25e2831adf2fb5442 +size 17 diff --git a/S2OJ/974/data/point11.in b/S2OJ/974/data/point11.in new file mode 100644 index 00000000..b5f2af3d --- /dev/null +++ b/S2OJ/974/data/point11.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2f0993fd3892a2aee2baf092fb73e762aa4788a7d0aa647703177b328ad2417c +size 10481 diff --git a/S2OJ/974/data/point11.out b/S2OJ/974/data/point11.out new file mode 100644 index 00000000..fcb7242e --- /dev/null +++ b/S2OJ/974/data/point11.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bf179561729bafca4e39904e68c997719d505e7869ad76a8ca8925988d9b5215 +size 14 diff --git a/S2OJ/974/data/point12.in b/S2OJ/974/data/point12.in new file mode 100644 index 00000000..124d30c1 --- /dev/null +++ b/S2OJ/974/data/point12.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b72229a94df329182dd3e2f5df781527bc4568b5b3d3d9ebcb50302ea7b8209 +size 7788 diff --git a/S2OJ/974/data/point12.out b/S2OJ/974/data/point12.out new file mode 100644 index 00000000..e308efea --- /dev/null +++ b/S2OJ/974/data/point12.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8842f743772bffaf666df0f18b2eb1e8ac2d3aed9afddd75c65cce8ee1a40dde +size 119 diff --git a/S2OJ/974/data/point13.in b/S2OJ/974/data/point13.in new file mode 100644 index 00000000..c15796f9 --- /dev/null +++ b/S2OJ/974/data/point13.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7269e8088b51316d70e4786f0bd6b957bb46d65c3e274d85813213fa59f92cf7 +size 840153 diff --git a/S2OJ/974/data/point13.out b/S2OJ/974/data/point13.out new file mode 100644 index 00000000..85aceaed --- /dev/null +++ b/S2OJ/974/data/point13.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1534fe60b659ac6f1cb5195d5cae847f1c8508a23748cf6f5db404df2f7734f2 +size 252 diff --git a/S2OJ/974/data/point14.in b/S2OJ/974/data/point14.in new file mode 100644 index 00000000..3cc25bf4 --- /dev/null +++ b/S2OJ/974/data/point14.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:83fe00ce12ab287cf99254f9ed766fe1a71348439a812ff874e71072aaada69c +size 1461384 diff --git a/S2OJ/974/data/point14.out b/S2OJ/974/data/point14.out new file mode 100644 index 00000000..67bb26c1 --- /dev/null +++ b/S2OJ/974/data/point14.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:af440854db8affbbdc5fa3683309e806f95aef2b3f570c95de76fc440f1c9d48 +size 44 diff --git a/S2OJ/974/data/point15.in b/S2OJ/974/data/point15.in new file mode 100644 index 00000000..49a52153 --- /dev/null +++ b/S2OJ/974/data/point15.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:83a475a45849881b04fee0c3a22df3bfede3ce8574c517505668e89329dc826a +size 1460672 diff --git a/S2OJ/974/data/point15.out b/S2OJ/974/data/point15.out new file mode 100644 index 00000000..31ca3417 --- /dev/null +++ b/S2OJ/974/data/point15.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9d726de8ed81ae481d740f314c3916b13aa61d27244a5b359aa14cc0acb6cfb8 +size 31 diff --git a/S2OJ/974/data/point16.in b/S2OJ/974/data/point16.in new file mode 100644 index 00000000..4a80fbb6 --- /dev/null +++ b/S2OJ/974/data/point16.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ebe0e67eae694cb02ab41ab386c8839c9b8d0016753abcfb9482d2d0f75b1984 +size 1460967 diff --git a/S2OJ/974/data/point16.out b/S2OJ/974/data/point16.out new file mode 100644 index 00000000..f8d2ddee --- /dev/null +++ b/S2OJ/974/data/point16.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2931cbfb64298a560854a6f3a0a2572cc3eed48a119630b7a7b3af5390571893 +size 26 diff --git a/S2OJ/974/data/point17.in b/S2OJ/974/data/point17.in new file mode 100644 index 00000000..2f67cfe4 --- /dev/null +++ b/S2OJ/974/data/point17.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9574f10fb40b789dbc9f07f537f8b632bfb9228d62db632402faacf2c71feee5 +size 3477288 diff --git a/S2OJ/974/data/point17.out b/S2OJ/974/data/point17.out new file mode 100644 index 00000000..e852a8e1 --- /dev/null +++ b/S2OJ/974/data/point17.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9243b4f84231786681252cdf88742fd8c00b434d4b45c3c24e92213178f02ad1 +size 67 diff --git a/S2OJ/974/data/point18.in b/S2OJ/974/data/point18.in new file mode 100644 index 00000000..88eeae5d --- /dev/null +++ b/S2OJ/974/data/point18.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2bc47e26b018a806effa0522eaf9bf95406e4a2fcf45c37317d4bcd33d933fbd +size 3477430 diff --git a/S2OJ/974/data/point18.out b/S2OJ/974/data/point18.out new file mode 100644 index 00000000..d3f265d5 --- /dev/null +++ b/S2OJ/974/data/point18.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f276a09858f9cd8ca0605653b8b4248828bf9cdbabf741ad8edd20355382c45f +size 45 diff --git a/S2OJ/974/data/point19.in b/S2OJ/974/data/point19.in new file mode 100644 index 00000000..bd8c82cf --- /dev/null +++ b/S2OJ/974/data/point19.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e362d07c24983cfefc22563e30b73b98a506232aa195e255a3f70e82f729f791 +size 3474940 diff --git a/S2OJ/974/data/point19.out b/S2OJ/974/data/point19.out new file mode 100644 index 00000000..2e5ad2dc --- /dev/null +++ b/S2OJ/974/data/point19.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c76c17082a231435c3db3199dc4e0d77f5966af6caae7ad154e7af05d606d2be +size 24 diff --git a/S2OJ/974/data/point2.in b/S2OJ/974/data/point2.in new file mode 100644 index 00000000..207b8dd1 --- /dev/null +++ b/S2OJ/974/data/point2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:468a228790b2ac8413598970cdba4b04f77fa25cef1fc68b341743c933c0784b +size 83 diff --git a/S2OJ/974/data/point2.out b/S2OJ/974/data/point2.out new file mode 100644 index 00000000..710b97dc --- /dev/null +++ b/S2OJ/974/data/point2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:049869c0957fec9ee2e74ee91278db670592af0f329142769d3ed5f9bcfdd6d9 +size 9 diff --git a/S2OJ/974/data/point20.in b/S2OJ/974/data/point20.in new file mode 100644 index 00000000..d5d59798 --- /dev/null +++ b/S2OJ/974/data/point20.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5df01d9be6be00ab2ed4487174bf52dfbb669a7b0c4756a44b0893dbc257550a +size 1454007 diff --git a/S2OJ/974/data/point20.out b/S2OJ/974/data/point20.out new file mode 100644 index 00000000..26192995 --- /dev/null +++ b/S2OJ/974/data/point20.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ca4531b8217f6fd7ace8799174c959a252092fe7dab9e880af83c9e31eeabdb +size 11 diff --git a/S2OJ/974/data/point3.in b/S2OJ/974/data/point3.in new file mode 100644 index 00000000..15d74d88 --- /dev/null +++ b/S2OJ/974/data/point3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:334e86dd526d2cb40f8f275f360b30acb5c8304a71796eaf97d46262bcc52bd0 +size 83 diff --git a/S2OJ/974/data/point3.out b/S2OJ/974/data/point3.out new file mode 100644 index 00000000..9a452297 --- /dev/null +++ b/S2OJ/974/data/point3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f8a0cf3a23e58580851e12feaecffe773b9a8d112787071c1e0b2c4c33f39ac0 +size 8 diff --git a/S2OJ/974/data/point4.in b/S2OJ/974/data/point4.in new file mode 100644 index 00000000..87c8129e --- /dev/null +++ b/S2OJ/974/data/point4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c6197780c84ce0d1c5bb61140d79b2a212cc3a97fa7c00dde06020eb681ecf0 +size 80 diff --git a/S2OJ/974/data/point4.out b/S2OJ/974/data/point4.out new file mode 100644 index 00000000..069b5794 --- /dev/null +++ b/S2OJ/974/data/point4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:294c7b5353acc9bd593fabebf0de016cf07562d65180fe0672eb26ef5995258d +size 9 diff --git a/S2OJ/974/data/point5.in b/S2OJ/974/data/point5.in new file mode 100644 index 00000000..d057fc8c --- /dev/null +++ b/S2OJ/974/data/point5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a48cb3051aaf33f7775bcede1c888ef0821fcb3203c5e4adfb8843fee0f60a47 +size 84 diff --git a/S2OJ/974/data/point5.out b/S2OJ/974/data/point5.out new file mode 100644 index 00000000..4ab2ec45 --- /dev/null +++ b/S2OJ/974/data/point5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0d80695a21cbf0b6f73258217222e46b46379b1fdd070ee75d773f3037a69ea6 +size 12 diff --git a/S2OJ/974/data/point6.in b/S2OJ/974/data/point6.in new file mode 100644 index 00000000..10888eba --- /dev/null +++ b/S2OJ/974/data/point6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5de3ae06596298634a60d93dab5c82c107e907ecf8d302fcbd670cf585d8ef3d +size 78 diff --git a/S2OJ/974/data/point6.out b/S2OJ/974/data/point6.out new file mode 100644 index 00000000..c6db8f62 --- /dev/null +++ b/S2OJ/974/data/point6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fa37d3b52c80eee6da2cd12f67c1d001681dadb74aeb53fb66c0251f7b4296e9 +size 9 diff --git a/S2OJ/974/data/point7.in b/S2OJ/974/data/point7.in new file mode 100644 index 00000000..3d428569 --- /dev/null +++ b/S2OJ/974/data/point7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b02326d0367a21fec451a328a206293bcb540425cbcdbb75a1a42045b983df0f +size 9953 diff --git a/S2OJ/974/data/point7.out b/S2OJ/974/data/point7.out new file mode 100644 index 00000000..5e7ddeb4 --- /dev/null +++ b/S2OJ/974/data/point7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:461c9db97531fe8788ed3e6441ac513e92a6010231849c88d5723d9670fa3b58 +size 68 diff --git a/S2OJ/974/data/point8.in b/S2OJ/974/data/point8.in new file mode 100644 index 00000000..d166334a --- /dev/null +++ b/S2OJ/974/data/point8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:86535c85030c79472131768dd8a633a787165597f796f2834d181111a6c7d357 +size 11286 diff --git a/S2OJ/974/data/point8.out b/S2OJ/974/data/point8.out new file mode 100644 index 00000000..889e3b51 --- /dev/null +++ b/S2OJ/974/data/point8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43e8b1464df7c4fbc626d012c29853e0ac708545ced4cec955bcd69c7457ed12 +size 19 diff --git a/S2OJ/974/data/point9.in b/S2OJ/974/data/point9.in new file mode 100644 index 00000000..3e1f9011 --- /dev/null +++ b/S2OJ/974/data/point9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f84ebe2ba56223dcbb903eb611b3d1dc428bee5452daaa45635b99f5b738fb56 +size 9964 diff --git a/S2OJ/974/data/point9.out b/S2OJ/974/data/point9.out new file mode 100644 index 00000000..763902b8 --- /dev/null +++ b/S2OJ/974/data/point9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d7f70aa4ec459870b2e34aa73ae44d35c9c08c24f5ef8cda5116f9d159e8ed06 +size 12 diff --git a/S2OJ/974/data/problem.conf b/S2OJ/974/data/problem.conf new file mode 100644 index 00000000..2660a71e --- /dev/null +++ b/S2OJ/974/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4478895d913d317338f7d5529c70508d62403e0ff330933aa40c8f94ebc4779 +size 179