Search is not available for this dataset
name
stringlengths
2
88
description
stringlengths
31
8.62k
public_tests
dict
private_tests
dict
solution_type
stringclasses
2 values
programming_language
stringclasses
5 values
solution
stringlengths
1
983k
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include<bits/stdc++.h> #define rg register #define fp( i , x , y ) for( rg int i=(x); i<=(y); ++i ) #define fq( i , x , y ) for( rg int i=(y); i>=(x); --i ) #define i60 long long using namespace std ; const int N = 1e5+10 , B = 325 , skc = 998244353 ; int lef[B] , rig[B] , pos[N] , n , k , a[N] , f[N] , las[...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int BASE = 998244353; const int SZ = 320; struct BlockData { int sumC; vector<long long> sumF; BlockData() {} }; int n, k, c[100100]; long long f[100100]; BlockData blocks[SZ]; long long calc(int i) { long long res = 0; int sumC = 0, block = i / SZ; for (i...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include<stdint.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #include<ext/rope> using namespace __gnu_pbds; using namespace __gnu_cxx; #define VIS(it,con) for(auto it=con.begin();it!=con.end();++it) #define pob pop_back #define pf push_front #define pof pop_front #define MIN(x,y) (x=mi...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define sz(x) int(x.size()) #define all(x) x.begin(),x.end() #define pii pair<int,int> #define P...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; const long long BIG = 1446803456761533460; const int Big = 336860180; stringstream sss; const int maxn = 100010; const int SQ = 400; const int maxnsq = maxn / SQ + 10; int n, k; int A[maxn], P[maxn]; map<int, int> lst; int block[maxnsq][maxn * 2];...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; const int MOD = 998244353; int n, a[MAXN], m, dp[MAXN], cnt[MAXN]; void add(int &a, int b) { a = (a + b) % MOD; } int main() { scanf("%d %d", &n, &m); for (register int i = 1; i <= n; ++i) scanf("%d", &a[i]); dp[0] = 1; for (register int i ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; int n, k; int a[100055]; int dp[100055]; int l[100055]; int r[100055]; int last[100055]; int dat[400055]; int high[400055]; int low[400055]; int lazy[400055]; vector<int> out[100055]; int d[100055]; void push(int from, int to) { high[to] += lazy...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include<bits/stdc++.h> #define R register #define ll long long using namespace std; const int MOD = 998244353; const int MAXN = 1e5+5; int n,m,pre[MAXN],head[MAXN],Le[355],Ri[355],bel[MAXN]; int tag[355],tot[355],p[MAXN],sum[355][MAXN],a[MAXN],dp[MAXN]; void Make_Group() { int len=sqrt(n),tot=0; for(R int i=1;i*len<...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize(3) using namespace std; int a1, a2, x1, x2, j, k, g[2000000], mi[2000000], ma[2000000]; int n, m, p[100005], num[100005], wen[100005], bz[2000000], la[2000000]; int s[2000000], f[100005]; int max1(int a, int b) { if (a > b) return a; return b; } ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, K = 320; const long long P = 998244353; int m; int a[N], pre[N]; map<int, int> mp; long long dp[N]; namespace blocks { int b[N], lft[K], rgt[K]; inline void build(int n) { int k = (int)sqrt(n); for (int i = 1; i <= n; ++i) b[i] = (i - 1) / k + 1;...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #include <ext/rope> using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; typedef long long ll; typedef long double ld; typedef complex...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2") using namespace std; using ll = long long; int a[101001]; int b[101010]; int dp[101010]; int p1[101010]; int p2[101010]; int ans = 0; int n, k; void add(int* __restrict a, int* __restrict dp, int n) { for (int i = 0; i < n; ++i) { ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int block = 350; int add(int x, int y) { x += y; if (x >= 998244353) x -= 998244353; return x; } int n, lim, a[N], b[N], last[N], lastlast[N], bel[N], f[N]; struct BlockType { int sumc, sz, l, r; int presum[(block << 1) + 10]; } tn[N ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ull = uint64_t; using ll = int64_t; using ld = long double; const int N = 200228; #ifndef BZ const int SQ = 160; #else const int SQ = 2; #endif const int RSQ = N / SQ; vector<int> a[N]; ll f[N]; int g[N]; const int INF = N * 5; const int MOD = 998244353; int ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int Pow(int a, int b, int md, int ans = 1) { for (; b; b >>= 1, a = a * a % md) if (b & 1) ans = ans * a % md; return ans; } const int MAXN = 1e5 + 10; const int SQ = 512; const int tof = SQ - 1; const int INF = 1e9; const int MOD = 998244353; int M[MAXN], ps[SQ][MA...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long INF = 0x3f3f3f3f; const int N = 2e5 + 10; const int M = 11; const double PI = acos(-1.0); const int blo = 320; inline void add(int &a, int b) { a += b; if (a >= 998244353) a -= 998244353; } int v[N]; int cnt[blo][(blo << 1) + 10], sum[blo]; int vc[N], w[...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class X, class Y> void amax(X &x, const Y &y) { if (x < y) x = y; } template <class X, class Y> void amin(X &x, const Y &y) { if (x > y) x = y; } const int INF = 1e9 + 10; const long long INFL = (long long)1e18 + 10; const int MAX = 1e5 + 10; const int MAXS = ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int K; void add(int &x, int y) { x = x + y; if (x >= 998244353) x -= 998244353; } int val[100008]; int dp[100008]; int bel[100008]; int n; struct oneblockforall { vector<int> inv; int cnt[100008]; int tag; int all; int l, r; void add(int &x, int y) { x =...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100002; const int MOD = 1000000007; const int MAGIC = 500; const int INF = 1e9; int n, k, prv[MAX_N], pos[MAX_N], a[MAX_N]; int nBlock, L[MAGIC + 2], R[MAGIC + 2], blockID[MAX_N]; int v[MAX_N], offset[MAGIC + 2], head[MAGIC + 2], ps[MAGIC + 2][MAX_N]; int ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> int n, k, a[100001], P = 998244353, lcol[100001], last[100001], f[100001], val[100001], pos[100001], block; inline int sub(int a, const int &b) { a -= b; return a < 0 ? a + P : a; } inline int add(int a, const int &b) { a += b; return a >= P ? a - P : a; } inline in...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2") using namespace std; using ll = signed long long; const int MOD = 998244353; int ultim[100005], penultim[100005], dp[100005], cate[100005], n, k, x; inline void add(ll &a, int b) { a += b; if (a >= MOD) a -= MOD; if (a < 0) a +=...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define sz(x) int(x.size()) #define all(x) x.begin(),x.end() #define pii pair<int,int> #define P...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; inline void read(long long &x) { char ch; bool flag = false; for (ch = getchar(); !isdigit(ch); ch = getchar()) if (ch == '-') flag = true; for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar()) ; x = flag ? -x : x; } inline void write(long long x...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MX_N = 1e5 + 5; const int MX_K = 1e5 + 5; const int MX_A = MX_N; const int MOD = 998244353; const int B = 300; int N, K, A[MX_N]; int pos[MX_A], prv[MX_N], dp[MX_N]; struct Bucket { int pre[B], cnt[B], offset; Bucket() { for (int i = (0); i <= (B - 1); ++i...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long mod = 998244353LL; int k; class Block { public: int aux; vector<long long> pre; int st, en; int lo, hi; vector<long long> vals; vector<int> dist; Block(int a, int b) { aux = 0; st = a; en = b; lo = 0; hi = 0; pre.push_back(0L...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include<stdint.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #include<ext/rope> using namespace __gnu_pbds; using namespace __gnu_cxx; #define VIS(it,con) for(auto it=con.begin();it!=con.end();++it) #define pob pop_back #define pf push_front #define pof pop_front #define MIN(x,y) (x=mi...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ii = pair<int, int>; using ll = long long; using db = long double; const int N = 1e5 + 5, K = 20, MOD = 1e9 + 7, MOD2 = 998244353; const ll MX = 1e15; const int blkSz = 320; int n, k, sq, a[N]; int dp[N], lz[blkSz]; int sweeped[N]; deque<int> dq[blkSz]; deque<int> val...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2") #define _CRT_SECURE_NO_WARNINGS # include <iostream> # include <cmath> # include <algorithm> # include <stdio.h> # include <cstdint> # include <cstring> # include <string> # include <cstdli...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define sz(x) int(x.size()) #define all(x) x.begin(),x.end() #define pii pair<int,int> #define P...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <typename T> bool GetMax(T &a, T b) { return (a < b) ? (a = b, true) : false; } template <typename T> bool GetMin(T &a, T b) { return (a > b) ? (a = b, true) : false; } const int N = 1e5 + 10; const int B = 20; const int MOD = 998244353; int D(int x, int y) { r...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2") using namespace std; template <class T1, class T2, class T3> struct triple { T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()){}; triple(T1 _a, T2 _b,...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> namespace IOStream { const int MAXR = 10000000; char _READ_[MAXR], _PRINT_[MAXR]; int _READ_POS_, _PRINT_POS_, _READ_LEN_; inline char readc() { if (!_READ_POS_) _READ_LEN_ = fread(_READ_, 1, MAXR, stdin); char c = _READ_[_READ_POS_++]; if (_READ_POS_ == MAXR) _READ_POS_ = 0; if (_READ_...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include<bits/stdc++.h> #define LL long long #define rep(i, s, t) for(register int i = s, i##end = t; i <= i##end; ++i) #define dwn(i, s, t) for(register int i = s, i##end = t; i >= i##end; --i) using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); for(;!isdigit(ch);ch=getchar())if(ch == '-'...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
python3
print (16)
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2") using namespace std; template <class T1, class T2, class T3> struct triple { T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()){}; triple(T1 _a, T2 _b,...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include<bits/stdc++.h> #define reg register #define F(i,a,b) for(reg int i=(a);i<=(b);i++) inline int read(); using namespace std; const int N=1e5+10,mod=998244353; int n,k,a[N],idx1[N],idx2[N],dp[N]; namespace block { #define val first #define id second pair<int,int>b[N]; int t,bel[N],L[N],R[N],add[N],c[N],s[N]; i...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define sf scanf #define pf printf #define pb push_back #define mp make_pair #define PI ( acos(-1.0) ) #define mod 998244353 #define IN freopen("C.in","r",stdin) #define OUT freopen("output.txt","w",stdout) #define ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int mn = 1e5, msq = 317, mod = 998244353; int n, sq, k, a[mn + 3]; int inp[mn + 3], lw[msq + 3], rw[msq + 3]; int num[mn + 3]; int topw[mn + 3], secw[mn + 3]; long long f[mn + 3]; long long Sumf[msq + 3][2 * msq + 3]; int add[msq + 3]; void Add(int l, int r, int ad) {...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define sz(x) int(x.size()) #define all(x) x.begin(),x.end() #define pii pair<int,int> #define P...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 7; const int MOD = 1e9 + 7; const int PIERW = 300; int ciag[MAX]; int ostatnie[MAX]; int poprzedni[MAX]; long long pomocnicza[MAX]; long long DP[MAX]; struct Blok { int lewa, prawa; long long suma; long long sumaDP[PIERW * 2 + 1]; void Aktualiz...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2") using namespace std; template <class T1, class T2, class T3> struct triple { T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()){}; triple(T1 _a, T2 _b,...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> inline void gn(T &first) { char c, sg = 0; while (c = getchar(), (c > '9' || c < '0') && c != '-') ; for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9'; c = getchar()) first = (first << 1) + (first << 3) + c ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; template <typename T> struct modular { constexpr modular() : val(0) {} constexpr modular(const modular<T>& _m) : val(_m.val) {} template <typename U> constexpr modular(const U& _r = U()) { val = -MOD <= _r && _r < MOD ? _r : _r % MOD; ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long INF = 0x3f3f3f3f; const int N = 2e5 + 10; const int M = 11; const double PI = acos(-1.0); const int blo = 320; inline void add(int &a, int b) { a += b; if (a >= 998244353) a -= 998244353; } int v[N]; int cnt[blo][(blo << 1) + 10], sum[blo]; int vc[N], w[...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <typename T> void maxtt(T& t1, T t2) { t1 = max(t1, t2); } template <typename T> void mintt(T& t1, T t2) { t1 = min(t1, t2); } bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = "URDL"; long long ln, lk, lm; void etp(b...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 100100; const int B = 300; const int Mod = 998244353; int n, k; int x[N]; vector<int> v[N]; int Cnt[N]; int Offset[B]; int Pref[B][B]; int Dp[N]; void add_self(int& a, int b) { a += b; if (a >= Mod) a -= Mod; assert(0 <= a && a < Mod); } void min_self(in...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define sz(x) int(x.size()) #define all(x) x.begin(),x.end() #define pii pair<int,int> #define P...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; pair<int, int> operator+(const pair<int, int> x, const int y) { return make_pair(x.first + y, x.second); } const int mxn = 131072, siz = 1, md = 998244353; int n, k, pl[mxn], pr[mxn], d[mxn], f[mxn], bl[mxn], cnt[512][256], tag[512]; pair<int, int> a[mxn], b[mxn], c[mxn];...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; pair<int, int> operator+(const pair<int, int> x, const int y) { return make_pair(x.first + y, x.second); } const int mxn = 131072, siz = 250, md = 998244353; int n, k, pl[mxn], pr[mxn], d[mxn], f[mxn], bl[mxn], cnt[512][256], tag[512]; pair<int, int> a[mxn], b[mxn], c[mxn...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2") using namespace std; template <class T1, class T2, class T3> struct triple { T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()){}; triple(T1 _a, T2 _b,...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MAXSIZE = 360; class Solution { public: int count(vector<int>& nums, int k) { int n = nums.size(); init(n, k); dp[0] = 1; for (int i = 0; i < n; ++i) { count(nums[i], i); } return dp[n]; } private: struct Block { Block() ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int f[100010], val[100010], sep[100010], cnt, k, h[100010], last[100010], n; int read() { int tmp = 0; char c = getchar(); while (c < '0' || c > '9') c = getchar(); while (c >= '0' && c <= '9') { tmp = tmp * 10 + c - '0'; c = getchar(); } return tmp; } s...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; inline void read(long long &x) { char ch; bool flag = false; for (ch = getchar(); !isdigit(ch); ch = getchar()) if (ch == '-') flag = true; for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar()) ; x = flag ? -x : x; } inline void write(long long x...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; int n, k, a[100005]; int last[100005], prelast[100005], dp[100005]; const int blocks = 400; const int blocknum = 300; void add(int &a, int b) { a += b; if (a >= 998244353) a -= 998244353; } void dec(int &a, int b) { a -= b; if (a < 0) a += 99...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class X, class Y> void amax(X &x, const Y &y) { if (x < y) x = y; } template <class X, class Y> void amin(X &x, const Y &y) { if (x > y) x = y; } const int INF = 1e9 + 10; const long long INFL = (long long)1e18 + 10; const int MAX = 1e5 + 10; const int MAXS = ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const long long INF = 1000 * 1000 * 1000 + 7; const int mod = 998244353; const long long LINF = (long long)INF * INF; double eps = 1e-10; const int MAX = 100005; const int MAGIC = 400; const int zsuv = 400; int n, k; int dp[MAX]; int a[MAX]; in...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #include <ext/rope> using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; random_device(rd); mt19937 rng(rd()); const long long FIXED_RAN...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int len = 300; int last[100002], prelast[100002], a[100000], dp[100000]; int mag[100000]; int block[100000 / 300][2 * len + 1]; int blsum[100000 / len]; template <typename T1, typename T2> ostream& operator<<(ostream& ostr, const pair<T1, T2...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e5 + 5; const int M = 505; const ll mod = 998244353; ll add(ll a, ll b) { return (a + b >= mod ? a + b - mod : a + b); } ll sub(ll a, ll b) { return (a - b < 0 ? a - b + mod : a - b); } ll mul(ll a, ll b) { return (a * b) % mod; } int n,...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define sz(x) int(x.size()) #define all(x) x.begin(),x.end() #define pii pair<int,int> #define P...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int b = 325; int dp[100005]; int a[100005], cnt[100005]; int s[100005], e[100005]; vector<int> v[100005]; struct bucket { int val[2 * b + 5]; int sum = 0; void rebuild(int s, int e) { for (int i = 0; i <= 2 * b; i++) val[i] = 0; ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int P = 998244353; const int N = 100010, B = 300; int n, b, c; int a[N], ans[N], lst[N], prv[N], tag[N]; int lazy[B]; struct Fw { int fw[N * 2]; void ch(int k, int x) { k += N; for (; k < N * 2; k += k & -k) if ((fw[k] += x) >= P) fw[k] -= P; } i...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const int inf = 0x3f3f3f3f; const int mod = 1e9 + 7; int a[maxn]; int n, k, sum; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> k; int lim = 1000000; if (k & 1) { n = 1999; a[1] = 0, a[2] = -1; sum = (k + 2001) / 2; ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> int q, sum[320][2 * 320]; int dp[100009], last[100009], last2[100009], v[100009]; inline void add(int &a, int b) { a += b; if (a >= 1000000007) a -= 1000000007; } inline void update(int t) { memset(sum[t], 0, sizeof sum[t]); int cnt = 0; for (int i = t * q + q; i > t * q; i--) { c...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse4,sse3,avx,avx2") #include <iostream> #include <immintrin.h> using namespace std; using ll = long long; int a[101001]; int b[101010]; int dp[101010]; int p1[101010]; int p2[101010]; int ans = 0; int n, k; #define mod 998244353 void add(int* __restrict a, in...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, k, unit, tot; int be[(100005)], st[(100005)], en[(100005)], a[(100005)], sum[355][355], f[(100005)], pre[(100005)], now[(100005)], lazy[(100005)], S[(100005)]; const int P = 998244353; template <typename T> void read(T& t) { t = 0; bool fl = true; char p = ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include<cstdio> #define mod 998244353 #define N 100039 #define W 139 #define ll long long #define I inline #define re register using namespace std; int lazy[N],k,ks=100,n,a[N],b[N],g[N],pre[N];ll dp[N],f[W][N],tot; I void add(int x){ re int i,now=x/ks,fr=x/ks*ks,en=x;tot+=dp[x]; for(i=fr;i<en;i++)f[now][b[i]]=0; fo...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long MOD = 998244353; long long mpow(long long a, long long b) { if (b == 0) return 1; long long t1 = mpow(a, b / 2); t1 *= t1; t1 %= MOD; if (b % 2) t1 *= a; t1 %= MOD; return t1; } const long long N = 1e5 + 5; const long long block = 315; vector<long lo...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 100100; const int B = 300; const int Mod = 998244353; int n, k; int x[N]; vector<int> v[N]; void add_self(int& a, int b) { a += b; if (a >= Mod) a -= Mod; } void min_self(int& a, int b) { a = min(a, b); } int Offset[B]; int Cnt[N]; int Pref[B][B]; int Dp[N...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; int n, k, a[100005]; int last[100005], prelast[100005], dp[100005]; const int blocks = 300; const int blocknum = 400; void add(int &a, int b) { a += b; if (a >= 998244353) a -= 998244353; } void dec(int &a, int b) { a -= b; if (a < 0) a += 99...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int MAXN = 1e5; const int B = 315; int cnt[1 + MAXN], dp[1 + MAXN]; vector<int> occ[1 + MAXN]; void add_self(int &x, int y) { x += y; if (x >= mod) x -= mod; } void min_self(int &x, int y) { x = min(x, y); } struct SQRT { int id, offse...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2") #define _CRT_SECURE_NO_WARNINGS # include <iostream> # include <cmath> # include <algorithm> # include <stdio.h> # include <cstdint> # include <cstring> # include <string> # include <cstdli...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> inline void gn(T &first) { char c, sg = 0; while (c = getchar(), (c > '9' || c < '0') && c != '-') ; for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9'; c = getchar()) first = (first << 1) + (first << 3) + c ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> constexpr int sqrt(int n) { int r = 0; while (r * r < n) { r++; } return r; } const int N = 100001; const int B = sqrt(N); const int MOD = 998244353; void update(int &x, int a) { x += a; if (x >= MOD) { x -= MOD; } } int n, limit, blocks, bdelta[B], value[N], sum[B], s...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ii = pair<int, int>; using ll = long long; using db = long double; const int N = 1e5 + 5, K = 20, MOD = 1e9 + 7, MOD2 = 998244353; const ll MX = 1e15; const int blkSz = 320; int n, k, sq, a[N]; int dp[N], lz[blkSz]; int sweeped[N]; deque<int> dq[blkSz]; deque<int> val...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; pair<int, int> operator+(const pair<int, int> x, const int y) { return make_pair(x.first + y, x.second); } const int mxn = 131072, siz = 250, md = 998244353; int n, k, pl[mxn], pr[mxn], d[mxn], f[mxn], bl[mxn], cnt[512][256], tag[512]; pair<int, int> a[mxn], b[mxn], c[mxn...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse4,sse3,avx,avx2") using namespace std; using ll = long long; int a[101001]; int b[101010]; int dp[101010]; int p1[101010]; int p2[101010]; int ans = 0; int n, k; void add(int* __restrict a, int* __restrict dp, int n) { int sum = 0;...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 2; const int magic = 350; const int mod = 998244353; const int inf = 1e9 + 7; vector<int> pos[N]; int n, ar[N], dp[N], sum[magic][magic], off[magic], pter[N], wow[N]; int ceil(int x, int y) { if (x % y == 0) { return x / y; } return x / y + 1; ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int P = 998244353; int n, k; inline int ad(int& x, int& y) { return (x + y > P ? x + y - P : x + y); } int A[200006], las[200006], pr[200006]; const int blo = 600; int bel[200006]; pair<int, int> B[200006]; int S[200006]; int val[200006], gv[200006], lz[200006], cur; ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> const int N = 1e5 + 5, M = N / 183 + 3; int bel[N], f[N], g[N], tag[M], s[M][183 + 3 << 1]; inline int read() { int now = 0; register char c = getchar(); for (; !isdigit(c); c = getchar()) ; for (; isdigit(c); now = now * 10 + c - 48, c = getchar()) ; return now; } void Update...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; int n, k, a[100010], pre[350], L[350], R[350], b[100010]; int c[2][100010], sum[350][100010], f[100010], u[350]; bool vis[350]; void change(int l, int r, int c) { int i = l; while (i <= r) { int N = pre[i]; if (L[N] == i && R[N] <= r) ...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize("Ofast", "unroll-loops") using namespace std; using ll = long long; const int N = 1e5 + 1, mod = 998244353; int n, k; int a[N], dp[N], pre[N], pre2[N], cnt[N]; int32_t main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int BASE = 998244353; const int SZ = 2; struct BlockData { int sumC; vector<long long> sumF; BlockData() {} }; int n, k, c[100100]; long long f[100100]; BlockData blocks[SZ]; long long calc(int i) { long long res = 0; int sumC = 0, block = i / SZ; for (int...
1129_D. Isolation
Find the number of ways to divide an array a of n integers into any number of disjoint non-empty segments so that, in each segment, there exist at most k distinct integers that appear exactly once. Since the answer can be large, find it modulo 998 244 353. Input The first line contains two space-separated integers n...
{ "input": [ "5 5\n1 2 3 4 5\n", "3 1\n1 1 2\n", "5 2\n1 1 2 1 3\n" ], "output": [ "16", "3", "14" ] }
{ "input": [ "50 1\n50 8 46 9 12 38 41 18 49 10 23 15 16 3 13 17 48 8 31 32 6 31 31 49 9 40 9 21 23 41 17 31 45 47 17 1 12 15 50 40 38 4 20 1 9 37 4 47 4 24\n", "100 30\n31 57 26 94 41 92 88 4 46 51 64 45 89 59 91 49 3 28 17 63 9 74 77 60 83 30 73 64 90 47 34 80 94 89 66 31 19 84 86 83 62 59 96 67 93 58 7 86 ...
IN-CORRECT
java
import java.io.*; import java.util.*; public class D { static class ModularArithmetic { private final int module; public ModularArithmetic(int module) { this.module = module; } public ModularArithmetic() { this(1_000_000_007); } final int s...
1149_E. Election Promises
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes. There are n cities in Byteland, co...
{ "input": [ "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "4 2\n2 1 1 5\n1 2\n3 4\n", "4 2\n1 5 1 5\n1 2\n3 4\n" ], "output": [ "LOSE\n", "WIN\n0 0 0 \n", "WIN\n1 5 1 5 \n", "LOSE\n" ] }
{ "input": [ "2 1\n1000000000 1000000000\n2 1\n", "3 2\n123 345 567\n1 2\n3 2\n", "3 0\n4 1 4\n", "3 2\n1 0 1\n3 2\n2 1\n", "3 0\n1 2 3\n", "3 2\n1 1 1\n1 2\n2 3\n", "2 0\n1000000000 1000000000\n", "2 0\n123456789 987654321\n", "3 2\n123 345 123\n1 2\n3 2\n", "1 0\n271828182\n"...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 100; int n, m, h[N], lev[N], Xor[N], cnt[N], deg[N]; vector<int> nxt[N], rnxt[N], vec[N]; set<int> s; queue<int> q; int main() { cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> h[i]; for (int i = 1; i <= m; ++i) { int x, y; cin >> x >> y...
1149_E. Election Promises
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes. There are n cities in Byteland, co...
{ "input": [ "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "4 2\n2 1 1 5\n1 2\n3 4\n", "4 2\n1 5 1 5\n1 2\n3 4\n" ], "output": [ "LOSE\n", "WIN\n0 0 0 \n", "WIN\n1 5 1 5 \n", "LOSE\n" ] }
{ "input": [ "2 1\n1000000000 1000000000\n2 1\n", "3 2\n123 345 567\n1 2\n3 2\n", "3 0\n4 1 4\n", "3 2\n1 0 1\n3 2\n2 1\n", "3 0\n1 2 3\n", "3 2\n1 1 1\n1 2\n2 3\n", "2 0\n1000000000 1000000000\n", "2 0\n123456789 987654321\n", "3 2\n123 345 123\n1 2\n3 2\n", "1 0\n271828182\n"...
CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize("O2") #pragma GCC optimize("unroll-loops") using namespace std; const long double eps = 1e-7; const int inf = 1000000010; const long long INF = 10000000000000010LL; const int mod = 1000000007; const int MAXN = 200010, LOG = 20; int n, m, k, u, v, x, y, t, a, b, ans; int A[M...
1149_E. Election Promises
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes. There are n cities in Byteland, co...
{ "input": [ "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "4 2\n2 1 1 5\n1 2\n3 4\n", "4 2\n1 5 1 5\n1 2\n3 4\n" ], "output": [ "LOSE\n", "WIN\n0 0 0 \n", "WIN\n1 5 1 5 \n", "LOSE\n" ] }
{ "input": [ "2 1\n1000000000 1000000000\n2 1\n", "3 2\n123 345 567\n1 2\n3 2\n", "3 0\n4 1 4\n", "3 2\n1 0 1\n3 2\n2 1\n", "3 0\n1 2 3\n", "3 2\n1 1 1\n1 2\n2 3\n", "2 0\n1000000000 1000000000\n", "2 0\n123456789 987654321\n", "3 2\n123 345 123\n1 2\n3 2\n", "1 0\n271828182\n"...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int he[200010], ver[2 * 200010], nxt[2 * 200010], tot, in[200010]; void add(int x, int y) { ver[++tot] = y; nxt[tot] = he[x]; he[x] = tot; } int que[200010], cnt; long long w[200010]; vector<int> v[200010]; long long ans[200010]; int s[200010]; bool vis[200010]; int m...
1149_E. Election Promises
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes. There are n cities in Byteland, co...
{ "input": [ "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "4 2\n2 1 1 5\n1 2\n3 4\n", "4 2\n1 5 1 5\n1 2\n3 4\n" ], "output": [ "LOSE\n", "WIN\n0 0 0 \n", "WIN\n1 5 1 5 \n", "LOSE\n" ] }
{ "input": [ "2 1\n1000000000 1000000000\n2 1\n", "3 2\n123 345 567\n1 2\n3 2\n", "3 0\n4 1 4\n", "3 2\n1 0 1\n3 2\n2 1\n", "3 0\n1 2 3\n", "3 2\n1 1 1\n1 2\n2 3\n", "2 0\n1000000000 1000000000\n", "2 0\n123456789 987654321\n", "3 2\n123 345 123\n1 2\n3 2\n", "1 0\n271828182\n"...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using i64 = long long; int n, m, h[223456], xors[223456], sg[223456], tag[223456]; int u, v, t, deg[223456], q[223456]; vector<int> e[223456]; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { scanf("%d", &h[i]); } for (int i = 0; i < m; i++) { ...
1149_E. Election Promises
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes. There are n cities in Byteland, co...
{ "input": [ "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "4 2\n2 1 1 5\n1 2\n3 4\n", "4 2\n1 5 1 5\n1 2\n3 4\n" ], "output": [ "LOSE\n", "WIN\n0 0 0 \n", "WIN\n1 5 1 5 \n", "LOSE\n" ] }
{ "input": [ "2 1\n1000000000 1000000000\n2 1\n", "3 2\n123 345 567\n1 2\n3 2\n", "3 0\n4 1 4\n", "3 2\n1 0 1\n3 2\n2 1\n", "3 0\n1 2 3\n", "3 2\n1 1 1\n1 2\n2 3\n", "2 0\n1000000000 1000000000\n", "2 0\n123456789 987654321\n", "3 2\n123 345 123\n1 2\n3 2\n", "1 0\n271828182\n"...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; vector<int> e[N]; int n, m, h[N], sg[N], sum[N], dg[N], q[N], vis[N]; void topsort() { int h = 1, t = 0; for (int i = 1; i <= n; i++) if (!dg[i]) q[++t] = i; while (h <= t) { int u = q[h++]; for (int v : e[u]) if (!--dg[v]) q[...
1149_E. Election Promises
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes. There are n cities in Byteland, co...
{ "input": [ "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "4 2\n2 1 1 5\n1 2\n3 4\n", "4 2\n1 5 1 5\n1 2\n3 4\n" ], "output": [ "LOSE\n", "WIN\n0 0 0 \n", "WIN\n1 5 1 5 \n", "LOSE\n" ] }
{ "input": [ "2 1\n1000000000 1000000000\n2 1\n", "3 2\n123 345 567\n1 2\n3 2\n", "3 0\n4 1 4\n", "3 2\n1 0 1\n3 2\n2 1\n", "3 0\n1 2 3\n", "3 2\n1 1 1\n1 2\n2 3\n", "2 0\n1000000000 1000000000\n", "2 0\n123456789 987654321\n", "3 2\n123 345 123\n1 2\n3 2\n", "1 0\n271828182\n"...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, y = 0, c = getchar(); while (!isdigit(c)) y = c, c = getchar(); while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar(); return y == '-' ? -x : x; } inline void print(long long q) { if (q < 0) putchar('-'), ...
1149_E. Election Promises
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes. There are n cities in Byteland, co...
{ "input": [ "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "4 2\n2 1 1 5\n1 2\n3 4\n", "4 2\n1 5 1 5\n1 2\n3 4\n" ], "output": [ "LOSE\n", "WIN\n0 0 0 \n", "WIN\n1 5 1 5 \n", "LOSE\n" ] }
{ "input": [ "2 1\n1000000000 1000000000\n2 1\n", "3 2\n123 345 567\n1 2\n3 2\n", "3 0\n4 1 4\n", "3 2\n1 0 1\n3 2\n2 1\n", "3 0\n1 2 3\n", "3 2\n1 1 1\n1 2\n2 3\n", "2 0\n1000000000 1000000000\n", "2 0\n123456789 987654321\n", "3 2\n123 345 123\n1 2\n3 2\n", "1 0\n271828182\n"...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <typename T> void maxtt(T& t1, T t2) { t1 = max(t1, t2); } template <typename T> void mintt(T& t1, T t2) { t1 = min(t1, t2); } bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = "URDL"; long long ln, lk, lm; void etp(b...
1149_E. Election Promises
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes. There are n cities in Byteland, co...
{ "input": [ "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "4 2\n2 1 1 5\n1 2\n3 4\n", "4 2\n1 5 1 5\n1 2\n3 4\n" ], "output": [ "LOSE\n", "WIN\n0 0 0 \n", "WIN\n1 5 1 5 \n", "LOSE\n" ] }
{ "input": [ "2 1\n1000000000 1000000000\n2 1\n", "3 2\n123 345 567\n1 2\n3 2\n", "3 0\n4 1 4\n", "3 2\n1 0 1\n3 2\n2 1\n", "3 0\n1 2 3\n", "3 2\n1 1 1\n1 2\n2 3\n", "2 0\n1000000000 1000000000\n", "2 0\n123456789 987654321\n", "3 2\n123 345 123\n1 2\n3 2\n", "1 0\n271828182\n"...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long head[400005], ver[400005], nxt[400005], cnt; void add(long long a, long long b) { ver[++cnt] = b, nxt[cnt] = head[a], head[a] = cnt; } vector<long long> e[400005], has[400005]; long long n, m, cd[400005]; long long a[400005], sg[400005]; long long pos[400005], m...
1149_E. Election Promises
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes. There are n cities in Byteland, co...
{ "input": [ "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "4 2\n2 1 1 5\n1 2\n3 4\n", "4 2\n1 5 1 5\n1 2\n3 4\n" ], "output": [ "LOSE\n", "WIN\n0 0 0 \n", "WIN\n1 5 1 5 \n", "LOSE\n" ] }
{ "input": [ "2 1\n1000000000 1000000000\n2 1\n", "3 2\n123 345 567\n1 2\n3 2\n", "3 0\n4 1 4\n", "3 2\n1 0 1\n3 2\n2 1\n", "3 0\n1 2 3\n", "3 2\n1 1 1\n1 2\n2 3\n", "2 0\n1000000000 1000000000\n", "2 0\n123456789 987654321\n", "3 2\n123 345 123\n1 2\n3 2\n", "1 0\n271828182\n"...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr int kMaxN = 2e5 + 3; vector<int> edges[kMaxN]; bitset<kMaxN> visited; int nim[kMaxN]; int mext[kMaxN]; int levels[kMaxN]; vector<int> nim_nodes[kMaxN]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; ...
1149_E. Election Promises
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes. There are n cities in Byteland, co...
{ "input": [ "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "4 2\n2 1 1 5\n1 2\n3 4\n", "4 2\n1 5 1 5\n1 2\n3 4\n" ], "output": [ "LOSE\n", "WIN\n0 0 0 \n", "WIN\n1 5 1 5 \n", "LOSE\n" ] }
{ "input": [ "2 1\n1000000000 1000000000\n2 1\n", "3 2\n123 345 567\n1 2\n3 2\n", "3 0\n4 1 4\n", "3 2\n1 0 1\n3 2\n2 1\n", "3 0\n1 2 3\n", "3 2\n1 1 1\n1 2\n2 3\n", "2 0\n1000000000 1000000000\n", "2 0\n123456789 987654321\n", "3 2\n123 345 123\n1 2\n3 2\n", "1 0\n271828182\n"...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class T> inline void chkmax(T &a, T b) { if (a < b) a = b; } template <class T> inline void chkmin(T &a, T b) { if (a > b) a = b; } inline int read() { int s = 0, f = 1; char ch = getchar(); while (!isdigit(ch) && ch != '-') ch = getchar(); if (ch == '...
1149_E. Election Promises
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes. There are n cities in Byteland, co...
{ "input": [ "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "4 2\n2 1 1 5\n1 2\n3 4\n", "4 2\n1 5 1 5\n1 2\n3 4\n" ], "output": [ "LOSE\n", "WIN\n0 0 0 \n", "WIN\n1 5 1 5 \n", "LOSE\n" ] }
{ "input": [ "2 1\n1000000000 1000000000\n2 1\n", "3 2\n123 345 567\n1 2\n3 2\n", "3 0\n4 1 4\n", "3 2\n1 0 1\n3 2\n2 1\n", "3 0\n1 2 3\n", "3 2\n1 1 1\n1 2\n2 3\n", "2 0\n1000000000 1000000000\n", "2 0\n123456789 987654321\n", "3 2\n123 345 123\n1 2\n3 2\n", "1 0\n271828182\n"...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, m; bool tmp[N]; int h[N], f[N], b[N]; vector<int> G[N]; int deg[N]; vector<int> ord; void topusort() { queue<int> Q; for (int i = 1; i <= n; i++) { if (!deg[i]) { Q.push(i); } } while (!Q.empty()) { int p = Q.front(); ...
1149_E. Election Promises
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes. There are n cities in Byteland, co...
{ "input": [ "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "4 2\n2 1 1 5\n1 2\n3 4\n", "4 2\n1 5 1 5\n1 2\n3 4\n" ], "output": [ "LOSE\n", "WIN\n0 0 0 \n", "WIN\n1 5 1 5 \n", "LOSE\n" ] }
{ "input": [ "2 1\n1000000000 1000000000\n2 1\n", "3 2\n123 345 567\n1 2\n3 2\n", "3 0\n4 1 4\n", "3 2\n1 0 1\n3 2\n2 1\n", "3 0\n1 2 3\n", "3 2\n1 1 1\n1 2\n2 3\n", "2 0\n1000000000 1000000000\n", "2 0\n123456789 987654321\n", "3 2\n123 345 123\n1 2\n3 2\n", "1 0\n271828182\n"...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int maxN = 2e5 + 10; int n, m, clk; int h[maxN + 1], vis[maxN + 1]; int p[maxN + 1], sum[maxN + 1]; vector<int> G[maxN + 1]; inline int read() { int num = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } ...
1149_E. Election Promises
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes. There are n cities in Byteland, co...
{ "input": [ "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "4 2\n2 1 1 5\n1 2\n3 4\n", "4 2\n1 5 1 5\n1 2\n3 4\n" ], "output": [ "LOSE\n", "WIN\n0 0 0 \n", "WIN\n1 5 1 5 \n", "LOSE\n" ] }
{ "input": [ "2 1\n1000000000 1000000000\n2 1\n", "3 2\n123 345 567\n1 2\n3 2\n", "3 0\n4 1 4\n", "3 2\n1 0 1\n3 2\n2 1\n", "3 0\n1 2 3\n", "3 2\n1 1 1\n1 2\n2 3\n", "2 0\n1000000000 1000000000\n", "2 0\n123456789 987654321\n", "3 2\n123 345 123\n1 2\n3 2\n", "1 0\n271828182\n"...
CORRECT
cpp
#include <bits/stdc++.h> const int N = 200007; int a[N], deg[N], pos[N], vis[N], sg[N], sum[N]; std::queue<int> q; std::vector<int> e[N]; int read() { int x = 0, c = getchar(); while (isspace(c)) c = getchar(); while (isdigit(c)) (x *= 10) += c & 15, c = getchar(); return x; } int main() { int n = read(), m =...
1149_E. Election Promises
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes. There are n cities in Byteland, co...
{ "input": [ "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "4 2\n2 1 1 5\n1 2\n3 4\n", "4 2\n1 5 1 5\n1 2\n3 4\n" ], "output": [ "LOSE\n", "WIN\n0 0 0 \n", "WIN\n1 5 1 5 \n", "LOSE\n" ] }
{ "input": [ "2 1\n1000000000 1000000000\n2 1\n", "3 2\n123 345 567\n1 2\n3 2\n", "3 0\n4 1 4\n", "3 2\n1 0 1\n3 2\n2 1\n", "3 0\n1 2 3\n", "3 2\n1 1 1\n1 2\n2 3\n", "2 0\n1000000000 1000000000\n", "2 0\n123456789 987654321\n", "3 2\n123 345 123\n1 2\n3 2\n", "1 0\n271828182\n"...
CORRECT
cpp
#include <bits/stdc++.h> inline void read(int& x) { char ch = getchar(); x = 0; while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); } const int N = 201000; struct Edge { int v, nxt; } a[N + N]; int head[N], Head[N]; int h[N], xr[N], deg[N], q[N]; int tng[N], sg[N]; ...
1149_E. Election Promises
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes. There are n cities in Byteland, co...
{ "input": [ "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "4 2\n2 1 1 5\n1 2\n3 4\n", "4 2\n1 5 1 5\n1 2\n3 4\n" ], "output": [ "LOSE\n", "WIN\n0 0 0 \n", "WIN\n1 5 1 5 \n", "LOSE\n" ] }
{ "input": [ "2 1\n1000000000 1000000000\n2 1\n", "3 2\n123 345 567\n1 2\n3 2\n", "3 0\n4 1 4\n", "3 2\n1 0 1\n3 2\n2 1\n", "3 0\n1 2 3\n", "3 2\n1 1 1\n1 2\n2 3\n", "2 0\n1000000000 1000000000\n", "2 0\n123456789 987654321\n", "3 2\n123 345 123\n1 2\n3 2\n", "1 0\n271828182\n"...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; vector<vector<int> > adj(200001); int c[200001], mex[200001], h[200001], b[200001]; void DFS(int i) { if (mex[i] >= 0) { return; } vector<int> v; for (int j : adj[i]) { DFS(j); v.push_back(mex[j]); } for (int x : v) { c[x] = i; } int &k = mex...
1149_E. Election Promises
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes. There are n cities in Byteland, co...
{ "input": [ "6 4\n2 2 5 5 6 6\n1 3\n2 4\n3 5\n4 6\n", "3 3\n314 159 265\n1 2\n1 3\n3 2\n", "4 2\n2 1 1 5\n1 2\n3 4\n", "4 2\n1 5 1 5\n1 2\n3 4\n" ], "output": [ "LOSE\n", "WIN\n0 0 0 \n", "WIN\n1 5 1 5 \n", "LOSE\n" ] }
{ "input": [ "2 1\n1000000000 1000000000\n2 1\n", "3 2\n123 345 567\n1 2\n3 2\n", "3 0\n4 1 4\n", "3 2\n1 0 1\n3 2\n2 1\n", "3 0\n1 2 3\n", "3 2\n1 1 1\n1 2\n2 3\n", "2 0\n1000000000 1000000000\n", "2 0\n123456789 987654321\n", "3 2\n123 345 123\n1 2\n3 2\n", "1 0\n271828182\n"...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5; int n, m, h[maxn + 3], xo[maxn + 3], deg[maxn + 3], sg[maxn + 3], vis[maxn + 3], res[maxn + 3]; vector<int> G[maxn + 3], H[maxn + 3]; int main() { scanf("%d %d", &n, &m); for (int i = (1); i <= int(n); i++) scanf("%d", &h[i]); for (int i = (1...