diff --git a/NFLSOJ/0/3632/3632.cpp b/NFLSOJ/0/3632/3632.cpp new file mode 100644 index 00000000..b0d4db88 --- /dev/null +++ b/NFLSOJ/0/3632/3632.cpp @@ -0,0 +1,42 @@ +#include +#include +#include +#include + +// using std::cin; +// using std::cout; +std::ifstream cin("segment.in"); +std::ofstream cout("segment.out"); +const char endl = '\n'; + +const int N = 5e5 + 5; +const int mod = 1e9 + 7; + +int n; +long long a[N], s[N], f[N], sum; +std::map map; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n; + + for (int i = 1; i <= n; i++) { + cin >> a[i]; + } + + std::partial_sum(a + 1, a + 1 + n, s + 1); + + f[0] = sum = 1; + + for (int i = 1; i <= n; i++) { + f[i] = sum; + sum = ((sum + f[i] - map[s[i]]) % mod + mod) % mod; + map[s[i]] = f[i]; + } + + cout << f[n] << endl; + + return 0; +} diff --git a/NFLSOJ/0/3632/samples/segment1.ans b/NFLSOJ/0/3632/samples/segment1.ans new file mode 100644 index 00000000..f2baf931 --- /dev/null +++ b/NFLSOJ/0/3632/samples/segment1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:10159baf262b43a92d95db59dae1f72c645127301661e0a3ce4e38b295a97c58 +size 2 diff --git a/NFLSOJ/0/3632/samples/segment1.in b/NFLSOJ/0/3632/samples/segment1.in new file mode 100644 index 00000000..8bbf7877 --- /dev/null +++ b/NFLSOJ/0/3632/samples/segment1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6455dc31124508f83ab3cbba66782ba1bb42e2ffa24eb2a0c18e3f562c18a49a +size 12 diff --git a/NFLSOJ/0/3632/samples/segment2.ans b/NFLSOJ/0/3632/samples/segment2.ans new file mode 100644 index 00000000..dff0a636 --- /dev/null +++ b/NFLSOJ/0/3632/samples/segment2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:95aebc97bc646c67fdcd923a5965b001f3c8a5c4d3a77075112e12a3a311d760 +size 3 diff --git a/NFLSOJ/0/3632/samples/segment2.in b/NFLSOJ/0/3632/samples/segment2.in new file mode 100644 index 00000000..0cefc7fe --- /dev/null +++ b/NFLSOJ/0/3632/samples/segment2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2f2ba370590867183e429a7e0aa26a578fa00b7bb79e76697d2850a2f155b198 +size 22 diff --git a/NFLSOJ/0/3632/samples/segment3.ans b/NFLSOJ/0/3632/samples/segment3.ans new file mode 100644 index 00000000..d595cdb8 --- /dev/null +++ b/NFLSOJ/0/3632/samples/segment3.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7de1555df0c2700329e815b93b32c571c3ea54dc967b89e81ab73b9972b72d1d +size 2 diff --git a/NFLSOJ/0/3632/samples/segment3.in b/NFLSOJ/0/3632/samples/segment3.in new file mode 100644 index 00000000..8d333dff --- /dev/null +++ b/NFLSOJ/0/3632/samples/segment3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f56bd304b7d542744c2f24d85a32435b7a5eb83cb4d4cb5ef9d51f480fbc6980 +size 10 diff --git a/NFLSOJ/0/3632/samples/segment4.ans b/NFLSOJ/0/3632/samples/segment4.ans new file mode 100644 index 00000000..ece789b7 --- /dev/null +++ b/NFLSOJ/0/3632/samples/segment4.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d42850abeed4c041d5bda99a0746e25abb28e9599c53ba9b7a07e39fa3f51b0b +size 8 diff --git a/NFLSOJ/0/3632/samples/segment4.in b/NFLSOJ/0/3632/samples/segment4.in new file mode 100644 index 00000000..c90f1a34 --- /dev/null +++ b/NFLSOJ/0/3632/samples/segment4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1780dcf584630cf66a9f8f766f151a9c61c8d76dbbc2d5fac963b5e2a06fdd1b +size 64 diff --git a/NFLSOJ/0/3632/samples/segment5.ans b/NFLSOJ/0/3632/samples/segment5.ans new file mode 100644 index 00000000..8292ba2a --- /dev/null +++ b/NFLSOJ/0/3632/samples/segment5.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:13c6880d7179ae84d37b1df8f0cd88629c1bba56153058d2c305e218eb5d8898 +size 10 diff --git a/NFLSOJ/0/3632/samples/segment5.in b/NFLSOJ/0/3632/samples/segment5.in new file mode 100644 index 00000000..313da124 --- /dev/null +++ b/NFLSOJ/0/3632/samples/segment5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e8e452aff4068d7352d3cd42e26bc1ff32e40bac2de4001c701b8887061f73d +size 533075