QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#181501#7219. The Mighty Spellucup-team288WA 18ms16444kbC++204.3kb2023-09-16 19:58:332023-09-16 19:58:33

Judging History

你现在查看的是最新测评结果

  • [2024-11-22 16:49:37]
  • hack成功,自动添加数据
  • (/hack/1236)
  • [2023-09-16 19:58:33]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:16444kb
  • [2023-09-16 19:58:33]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using i64 = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l)==r], ++l; }
#else
#define DE(...) 0
#define debug(...) 0
#endif

const int MAX_N = 200010, MAX_M = 51, p = 1e9 + 7;

using ap = array<int, MAX_M>;
int n, m;
int c[MAX_N];
ll cnt[MAX_M];
ll w[MAX_N], iw[MAX_N], p2[MAX_N];
ll wb[MAX_N], iwb[MAX_N];
ll pf[MAX_N];
ap lst[MAX_N];

ll inv[MAX_N];
ll g(ll x) {
	return (2 * x * x % p * x % p
		+ 3 * x * x % p
		+ 3 * x + 3) % p;
}
void mul(ll &a, ll b) {
	a = (a * b) % p;
}
void add(ll &a, ll b) {
	a = (a + b) % p;
}
ll bin_pow(ll v, ll t) {
	ll ret = 1;
	for (;t;t>>=1, mul(v, v))
		if (t&1) mul(ret, v);
	return ret;
}

void init() {
	inv[0] = inv[1] = 1;
	p2[0] = 1;
	p2[1] = 2;
	for (int i = 2;i < MAX_N;++i) {
		inv[i] = (p-p/i) * inv[p % i] % p;
		p2[i] = p2[i-1] * 2 % p;
	}
	for (int i = 1;i < MAX_N;++i)
		pf[i] = (pf[i-1] + g(i) * bin_pow(inv[2], i)) % p;
}
ll f(int i) {
	//return 12 * i;
	return 12 * i - 10;
}
ll get_g(ll l, ll r, ll clen) {
	ll ret = 0;
	assert(clen >= r);
	for (int i = l;i <= r;++i) {
		add(ret, p2[clen - i] * f(i));
	}
	return ret;
}

ll cont(ll l, ll r) {
	vector<int> has(m+1);
	for (int i = l;i <= r;++i)
		has[ c[i] ] = true;
	
	vector<int> cnt(m+1);
	for (int i = 1;i+1 < l;++i)
		++cnt[ c[i] ];
	for (int i = r+2;i <= n;++i)
		++cnt[ c[i] ];

	ll ret = g(r - l + 1);
	for (int i = 1;i <= m;++i) {
		if (has[i]) mul(ret, p2[cnt[i]]);
		else mul(ret, p2[cnt[i]] - 1);
	}
	return ret;

}
int main() {
	cin.tie(nullptr)->sync_with_stdio(false);
	init();
	DE(g(1), g(2), g(3), g(2) + g(3) + 2  * g(1));
	cin >> n >> m;
	for (int i = 1;i <= n;++i)
		cin >> c[i];
	for (int i = 1;i <= n;++i) {
		lst[i] = lst[i-1];
		lst[i][c[i]] = i;
		++cnt[c[i]];
	} 
	for (int i = 1;i <= m;++i) {
		w[i] = p2[cnt[i]] - 1;
		iw[i] = bin_pow(w[i], p-2);
		if (cnt[i] > 0)
			wb[i] = p2[cnt[i]-1] - 1;
		else
			wb[i] = 0;
		iwb[i] = bin_pow(wb[i], p-2);
		//DE(i, w[i]);
	}
	ll res = 0;

	for (int r = 1;r <= n;++r) {
		if (r+1 <= n && cnt[ c[r+1] ] == 1) continue;

		int nxt_c = c[r+1];
		if (nxt_c) {
			--cnt[nxt_c];
			swap(w[nxt_c], wb[nxt_c]);
			swap(iw[nxt_c], iwb[nxt_c]);
		}

		ll cur_v = 1;
		for (int i = 1;i <= m;++i) {
			DE(i, cnt[i]);
			//mul(cur_v, p2[ cnt[i] ]-1);
			mul(cur_v, w[i]);
		}

		vector<int> sid(m+1); iota(AI(sid), 0);
		sort(AI(sid), [&](int a, int b) {
				return lst[r][a] > lst[r][b];
				});

		DE(r);
		int clen = 0;
		for (int j = 0;;++j) {
			int p1 = lst[r][ sid[j] ];
			clen += cnt[ sid[j] ];

			DE(clen, sid[j], cnt[ sid[j] ]);

			if (p1 == 0) {
				// len = r
				//ll sc = cur_v;
				add(res, cur_v * g(r) % p * p2[clen-r]);
				ll v = cur_v * g(r) % p * p2[clen-r];
				//assert(v == cont(1, r));
				break;
			}

			mul(cur_v, iw[ sid[j] ]);

			if (cnt[ sid[j] ] > 1) {
				clen -= cnt[ sid[j] ];
				ll sc = cur_v; 
				mul(sc, p2[ cnt[sid[j]]-1 ] - 1); 
				int O = r - p1;
				if (O > 0) {
					ll v = sc * g(O) % p * p2[clen - O] % p;
					add(res, v);
				}
				clen += cnt[ sid[j] ];
			}

			int p2 = lst[r][ sid[j+1] ];
			int L = r-p1+1, R = r-p2-1; 
			DE(j, cur_v, L, R, r);

			//upd(L, R, clen, cur_v);

			if (L <= R) {
				ll v = (pf[R] - pf[L-1] + p) % p
					* ::p2[clen - 1] % p; 
				add(res, v * cur_v);
			}

//			for (int j = L;j <= R;++j) {
//				ll v = g(j) * cur_v % p * ::p2[clen - 1 - j] % p;
//
////				int lb = r - j + 1;
////				DE(v, cont(r - j + 1, r), lb, cur_v, g(j), clen - 1 - j);
//				assert(cont(r - j + 1, r) == v);
//				add(res, v);
//			}
			//add(res, get_g(L, R, clen) * cur_v % p * );
		}

		if (nxt_c) {
			++cnt[nxt_c];
			swap(w[nxt_c], wb[nxt_c]);
			swap(iw[nxt_c], iwb[nxt_c]);
		}
	}
	if (res < 0) res += p;
	cout << res << '\n'; 
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 17ms
memory: 15896kb

input:

3 2
1 2 2

output:

152

result:

ok answer is '152'

Test #2:

score: 0
Accepted
time: 14ms
memory: 14884kb

input:

4 3
1 2 1 2

output:

0

result:

ok answer is '0'

Test #3:

score: 0
Accepted
time: 14ms
memory: 15568kb

input:

6 3
1 2 3 3 2 1

output:

3627

result:

ok answer is '3627'

Test #4:

score: 0
Accepted
time: 17ms
memory: 15080kb

input:

5 5
1 4 5 3 2

output:

343

result:

ok answer is '343'

Test #5:

score: 0
Accepted
time: 14ms
memory: 16064kb

input:

5 5
1 5 4 3 2

output:

343

result:

ok answer is '343'

Test #6:

score: 0
Accepted
time: 17ms
memory: 13744kb

input:

5 5
3 1 5 4 2

output:

343

result:

ok answer is '343'

Test #7:

score: 0
Accepted
time: 18ms
memory: 14936kb

input:

5 5
4 1 2 3 5

output:

343

result:

ok answer is '343'

Test #8:

score: 0
Accepted
time: 17ms
memory: 15452kb

input:

5 5
2 3 2 2 2

output:

0

result:

ok answer is '0'

Test #9:

score: 0
Accepted
time: 3ms
memory: 15676kb

input:

5 5
1 2 2 2 5

output:

0

result:

ok answer is '0'

Test #10:

score: 0
Accepted
time: 10ms
memory: 14896kb

input:

5 5
4 2 1 3 5

output:

343

result:

ok answer is '343'

Test #11:

score: 0
Accepted
time: 14ms
memory: 15520kb

input:

5 5
2 3 4 5 1

output:

343

result:

ok answer is '343'

Test #12:

score: 0
Accepted
time: 18ms
memory: 15660kb

input:

5 5
4 3 5 2 1

output:

343

result:

ok answer is '343'

Test #13:

score: 0
Accepted
time: 10ms
memory: 15240kb

input:

5 5
3 4 5 2 1

output:

343

result:

ok answer is '343'

Test #14:

score: 0
Accepted
time: 14ms
memory: 15608kb

input:

5 5
4 3 3 5 2

output:

0

result:

ok answer is '0'

Test #15:

score: 0
Accepted
time: 17ms
memory: 15648kb

input:

5 5
1 4 4 1 1

output:

0

result:

ok answer is '0'

Test #16:

score: 0
Accepted
time: 17ms
memory: 14592kb

input:

5 5
1 5 2 4 3

output:

343

result:

ok answer is '343'

Test #17:

score: 0
Accepted
time: 7ms
memory: 14032kb

input:

5 5
4 2 5 3 1

output:

343

result:

ok answer is '343'

Test #18:

score: 0
Accepted
time: 14ms
memory: 14868kb

input:

5 5
3 1 4 5 2

output:

343

result:

ok answer is '343'

Test #19:

score: 0
Accepted
time: 17ms
memory: 14744kb

input:

5 5
5 1 3 4 2

output:

343

result:

ok answer is '343'

Test #20:

score: 0
Accepted
time: 12ms
memory: 14736kb

input:

5 5
4 5 3 5 5

output:

0

result:

ok answer is '0'

Test #21:

score: 0
Accepted
time: 18ms
memory: 16220kb

input:

5 5
2 2 3 4 2

output:

0

result:

ok answer is '0'

Test #22:

score: 0
Accepted
time: 10ms
memory: 14880kb

input:

5 5
4 5 1 2 3

output:

343

result:

ok answer is '343'

Test #23:

score: 0
Accepted
time: 14ms
memory: 15512kb

input:

5 5
3 5 1 2 4

output:

343

result:

ok answer is '343'

Test #24:

score: 0
Accepted
time: 17ms
memory: 15680kb

input:

5 5
5 4 1 2 3

output:

343

result:

ok answer is '343'

Test #25:

score: 0
Accepted
time: 18ms
memory: 15020kb

input:

5 5
5 3 4 1 2

output:

343

result:

ok answer is '343'

Test #26:

score: 0
Accepted
time: 7ms
memory: 13824kb

input:

5 5
3 1 2 1 5

output:

0

result:

ok answer is '0'

Test #27:

score: 0
Accepted
time: 13ms
memory: 15236kb

input:

5 5
3 1 4 2 5

output:

343

result:

ok answer is '343'

Test #28:

score: 0
Accepted
time: 17ms
memory: 16052kb

input:

5 5
1 2 4 5 3

output:

343

result:

ok answer is '343'

Test #29:

score: 0
Accepted
time: 17ms
memory: 14680kb

input:

5 5
4 3 1 5 2

output:

343

result:

ok answer is '343'

Test #30:

score: 0
Accepted
time: 18ms
memory: 14512kb

input:

5 5
2 1 3 4 5

output:

343

result:

ok answer is '343'

Test #31:

score: 0
Accepted
time: 18ms
memory: 14948kb

input:

5 5
4 2 1 3 5

output:

343

result:

ok answer is '343'

Test #32:

score: 0
Accepted
time: 13ms
memory: 15316kb

input:

5 5
4 3 1 4 3

output:

0

result:

ok answer is '0'

Test #33:

score: 0
Accepted
time: 18ms
memory: 15776kb

input:

5 5
3 4 1 1 3

output:

0

result:

ok answer is '0'

Test #34:

score: 0
Accepted
time: 18ms
memory: 15816kb

input:

20 5
5 2 5 1 5 5 2 4 5 5 2 5 5 5 5 4 2 5 3 4

output:

102882880

result:

ok answer is '102882880'

Test #35:

score: 0
Accepted
time: 17ms
memory: 15376kb

input:

20 5
3 2 1 2 2 2 2 2 4 3 2 2 3 3 5 2 2 1 2 5

output:

134653185

result:

ok answer is '134653185'

Test #36:

score: 0
Accepted
time: 10ms
memory: 14284kb

input:

20 5
1 2 3 2 1 3 5 1 2 4 5 2 3 4 5 1 4 3 4 5

output:

315505338

result:

ok answer is '315505338'

Test #37:

score: 0
Accepted
time: 18ms
memory: 14864kb

input:

20 5
5 2 2 4 2 3 5 1 1 3 1 5 2 4 4 3 1 4 3 5

output:

312062382

result:

ok answer is '312062382'

Test #38:

score: 0
Accepted
time: 14ms
memory: 15712kb

input:

20 5
3 4 2 5 4 5 5 4 1 4 3 3 4 3 4 2 3 2 5 3

output:

188515821

result:

ok answer is '188515821'

Test #39:

score: 0
Accepted
time: 14ms
memory: 15908kb

input:

20 5
3 5 1 3 3 4 5 2 1 1 3 1 2 5 2 1 1 2 5 2

output:

197857329

result:

ok answer is '197857329'

Test #40:

score: 0
Accepted
time: 17ms
memory: 14628kb

input:

20 10
3 8 6 8 9 2 1 5 8 6 7 8 4 8 6 8 10 8 8 8

output:

4905343

result:

ok answer is '4905343'

Test #41:

score: 0
Accepted
time: 8ms
memory: 15888kb

input:

20 10
10 5 1 8 7 2 7 2 6 2 2 2 2 2 4 2 3 7 9 7

output:

3724041

result:

ok answer is '3724041'

Test #42:

score: 0
Accepted
time: 14ms
memory: 14952kb

input:

20 10
5 1 9 6 10 4 5 3 2 4 8 3 7 1 8 6 2 9 10 7

output:

52978806

result:

ok answer is '52978806'

Test #43:

score: 0
Accepted
time: 18ms
memory: 16444kb

input:

20 10
5 8 6 2 1 10 3 8 9 7 6 5 10 9 1 7 3 4 4 2

output:

53309955

result:

ok answer is '53309955'

Test #44:

score: 0
Accepted
time: 10ms
memory: 15052kb

input:

20 10
1 8 1 7 9 7 9 9 7 4 1 6 2 7 8 6 6 9 6 7

output:

0

result:

ok answer is '0'

Test #45:

score: 0
Accepted
time: 14ms
memory: 14736kb

input:

20 10
1 10 10 10 2 9 1 1 7 2 3 9 5 10 8 4 1 4 2 5

output:

0

result:

ok answer is '0'

Test #46:

score: 0
Accepted
time: 18ms
memory: 15608kb

input:

20 20
9 16 3 18 8 19 6 4 2 17 1 15 10 11 5 13 12 7 14 20

output:

17263

result:

ok answer is '17263'

Test #47:

score: 0
Accepted
time: 14ms
memory: 15772kb

input:

20 20
2 17 18 12 15 20 11 9 10 5 6 16 7 8 4 13 3 1 19 14

output:

17263

result:

ok answer is '17263'

Test #48:

score: 0
Accepted
time: 18ms
memory: 15928kb

input:

20 20
14 15 19 8 3 20 9 12 18 7 5 11 4 2 16 6 1 17 10 13

output:

17263

result:

ok answer is '17263'

Test #49:

score: 0
Accepted
time: 17ms
memory: 15588kb

input:

20 20
18 9 3 4 13 12 15 11 2 16 19 7 10 20 17 8 6 1 14 5

output:

17263

result:

ok answer is '17263'

Test #50:

score: 0
Accepted
time: 14ms
memory: 14836kb

input:

20 20
7 6 4 14 20 13 1 15 5 18 16 10 1 16 12 14 5 13 1 3

output:

0

result:

ok answer is '0'

Test #51:

score: 0
Accepted
time: 17ms
memory: 14752kb

input:

20 20
17 17 5 16 9 14 14 1 2 4 19 8 9 5 9 20 5 16 20 9

output:

0

result:

ok answer is '0'

Test #52:

score: 0
Accepted
time: 17ms
memory: 14976kb

input:

20 20
20 1 16 5 19 11 8 7 2 3 12 6 17 14 13 18 4 10 15 9

output:

17263

result:

ok answer is '17263'

Test #53:

score: 0
Accepted
time: 10ms
memory: 15576kb

input:

20 20
2 13 6 1 17 3 11 9 8 10 7 5 16 14 4 15 18 19 20 12

output:

17263

result:

ok answer is '17263'

Test #54:

score: 0
Accepted
time: 18ms
memory: 14644kb

input:

20 20
17 11 13 5 2 14 18 7 6 9 10 3 16 15 8 1 19 4 12 20

output:

17263

result:

ok answer is '17263'

Test #55:

score: 0
Accepted
time: 14ms
memory: 15244kb

input:

20 20
7 13 1 15 9 2 8 20 4 5 12 3 11 14 10 18 6 17 16 19

output:

17263

result:

ok answer is '17263'

Test #56:

score: 0
Accepted
time: 17ms
memory: 15012kb

input:

20 20
11 8 17 7 10 20 20 12 7 3 7 14 15 4 14 7 11 1 12 20

output:

0

result:

ok answer is '0'

Test #57:

score: 0
Accepted
time: 13ms
memory: 15500kb

input:

20 20
20 18 17 14 11 2 13 3 10 1 16 3 1 16 10 8 4 8 13 3

output:

0

result:

ok answer is '0'

Test #58:

score: 0
Accepted
time: 13ms
memory: 16264kb

input:

20 20
1 20 7 4 18 11 9 8 3 6 16 13 19 2 12 14 15 17 10 5

output:

17263

result:

ok answer is '17263'

Test #59:

score: 0
Accepted
time: 14ms
memory: 14448kb

input:

20 20
8 4 5 18 16 15 19 2 13 1 14 7 10 12 17 3 6 9 20 11

output:

17263

result:

ok answer is '17263'

Test #60:

score: 0
Accepted
time: 14ms
memory: 16008kb

input:

20 20
13 14 8 9 18 17 20 6 15 3 2 16 12 11 1 10 19 4 7 5

output:

17263

result:

ok answer is '17263'

Test #61:

score: 0
Accepted
time: 18ms
memory: 15792kb

input:

20 20
4 10 17 8 19 1 16 3 14 6 7 11 13 15 20 9 12 5 2 18

output:

17263

result:

ok answer is '17263'

Test #62:

score: 0
Accepted
time: 17ms
memory: 15500kb

input:

20 20
19 17 19 8 7 1 18 13 16 16 20 11 5 8 17 19 11 14 4 8

output:

0

result:

ok answer is '0'

Test #63:

score: 0
Accepted
time: 9ms
memory: 15540kb

input:

20 20
7 1 14 13 20 16 10 18 16 12 5 7 16 14 6 12 11 20 10 19

output:

0

result:

ok answer is '0'

Test #64:

score: 0
Accepted
time: 10ms
memory: 14436kb

input:

500 5
3 5 5 3 5 3 5 5 3 3 3 3 3 3 1 3 3 3 3 3 3 3 5 3 3 3 1 3 3 3 3 5 3 3 3 3 3 3 3 3 3 3 5 3 3 3 5 3 3 5 2 3 3 3 5 3 3 3 3 1 3 3 5 3 3 5 3 3 5 3 5 3 3 3 3 3 3 5 3 5 3 3 5 3 5 3 5 3 3 3 3 3 3 3 3 3 3 3 3 3 5 3 3 3 3 3 3 3 3 3 3 3 5 3 3 3 3 3 3 3 5 3 3 5 5 3 3 3 3 3 5 3 5 3 3 3 3 5 3 3 3 3 3 3 3 3 3 ...

output:

255072751

result:

ok answer is '255072751'

Test #65:

score: 0
Accepted
time: 18ms
memory: 14908kb

input:

500 5
1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 5 1 5 5 1 1 1 1 1 5 5 1 1 1 1 5 4 5 4 1 1 1 1 1 1 5 1 1 5 1 1 5 1 5 1 1 1 1 1 4 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 4 1 5 1 5 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 5 1 1 3 4 5 1 5 1 1 1 1 5 5 1 1 1 1 1 1 1 1 5 1 1 1 5 1 1 1 1 5 1 5 1 4 1 1 1 4 5 5 1 ...

output:

825435010

result:

ok answer is '825435010'

Test #66:

score: 0
Accepted
time: 17ms
memory: 15324kb

input:

500 5
1 2 4 3 2 2 4 5 4 2 4 2 5 5 5 5 1 4 1 2 4 4 2 1 2 5 4 3 1 1 2 4 3 3 2 3 4 5 4 1 3 2 3 3 5 2 2 3 2 2 3 2 5 2 1 1 3 1 4 2 4 3 3 2 4 1 5 2 4 3 3 3 2 2 3 3 4 5 2 1 4 3 5 5 2 2 3 4 3 1 5 4 3 1 3 1 5 1 3 1 3 2 5 3 1 2 2 5 4 4 5 5 4 1 2 1 4 5 1 4 3 5 4 1 4 5 3 3 4 3 4 2 2 5 5 3 4 5 3 5 3 5 3 1 2 2 2 ...

output:

451686600

result:

ok answer is '451686600'

Test #67:

score: 0
Accepted
time: 14ms
memory: 14956kb

input:

500 5
4 1 3 1 1 1 4 1 1 5 1 5 3 5 4 1 1 4 2 5 5 5 2 5 2 2 5 3 1 5 3 3 2 5 4 5 1 3 4 3 5 1 5 3 1 3 5 2 2 3 2 4 2 3 5 5 3 1 5 3 2 4 2 1 2 1 5 4 3 5 2 5 5 4 2 3 1 5 4 4 3 1 3 3 1 3 3 4 3 1 2 2 3 4 3 1 2 3 4 1 1 1 5 4 2 3 4 5 4 1 2 4 3 3 4 5 3 3 4 4 2 4 5 5 3 2 2 1 5 2 4 2 2 2 2 1 4 3 5 3 4 3 5 5 3 3 5 ...

output:

377242617

result:

ok answer is '377242617'

Test #68:

score: 0
Accepted
time: 14ms
memory: 15024kb

input:

500 5
1 3 2 1 1 5 2 5 5 1 4 4 1 3 2 2 4 1 4 2 4 3 5 4 4 3 2 1 2 2 2 2 4 5 4 1 2 3 3 4 4 3 3 2 4 5 3 5 1 1 1 3 4 5 2 3 3 5 4 4 1 1 2 3 1 3 2 1 2 4 1 4 2 3 1 3 4 2 2 3 1 3 1 1 5 4 2 4 1 5 5 5 5 3 1 2 4 3 1 4 3 4 2 2 3 1 5 2 3 4 4 2 4 2 4 3 5 4 3 1 1 4 4 1 5 3 2 1 5 1 5 4 4 4 5 1 5 3 2 5 4 4 2 3 3 3 3 ...

output:

416085601

result:

ok answer is '416085601'

Test #69:

score: 0
Accepted
time: 18ms
memory: 14820kb

input:

500 5
1 3 4 5 5 5 3 3 4 4 1 3 2 1 1 5 4 4 3 1 3 4 3 4 3 1 4 4 1 4 4 3 4 4 1 1 3 2 1 5 4 2 2 3 3 2 3 4 5 5 5 2 3 4 1 5 2 5 5 4 4 2 5 5 1 1 5 3 4 1 1 1 4 2 4 5 2 4 3 5 1 5 1 4 4 3 4 5 5 5 1 1 4 5 5 1 2 3 3 4 3 4 3 3 1 5 4 5 4 2 1 1 4 5 2 1 4 2 1 1 3 3 1 5 2 1 2 3 2 3 3 1 5 1 4 3 4 4 2 4 4 1 4 4 3 1 4 ...

output:

320473255

result:

ok answer is '320473255'

Test #70:

score: 0
Accepted
time: 13ms
memory: 14596kb

input:

500 10
7 7 7 5 5 7 7 7 7 7 7 5 7 5 5 7 7 7 6 5 7 7 7 7 5 6 7 7 7 7 7 7 5 7 7 7 9 7 7 7 5 5 7 7 7 7 7 5 7 5 7 7 7 5 5 5 7 5 5 6 5 7 5 5 5 7 7 5 5 7 9 7 5 7 6 7 7 5 7 7 7 7 7 7 7 7 6 7 5 7 7 5 5 7 7 7 7 7 7 7 7 7 7 5 7 7 5 7 7 7 7 7 5 7 7 7 5 7 7 7 7 7 7 6 7 7 9 5 5 5 5 7 7 7 7 7 7 7 7 7 7 7 7 7 5 7 4...

output:

239772932

result:

ok answer is '239772932'

Test #71:

score: 0
Accepted
time: 14ms
memory: 14760kb

input:

500 10
1 1 9 10 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 9 1 1 6 1 1 1 1 7 1 1 9 10 9 1 1 1 1 1 9 1 1 1 10 1 1 1 1 1 1 1 10 1 10 10 1 1 1 7 1 10 1 1 1 1 1 1 1 10 1 1 1 1 10 9 1 1 9 10 1 1 1 1 1 1 1 10 1 10 9 1 1 1 10 10 10 1 1 1 1 9 3 9 1 1 1 1 10 1 1 1 1 10 1 1 10 7 1 1 1 1 1 1 9 1 1 1 1 1 10 1 10 1 1 1 1...

output:

516842141

result:

ok answer is '516842141'

Test #72:

score: 0
Accepted
time: 18ms
memory: 15248kb

input:

500 10
7 4 8 5 5 1 7 10 2 1 1 4 2 5 3 10 8 7 1 9 2 1 2 1 3 3 5 3 4 3 10 1 1 5 7 1 10 1 6 6 4 8 7 5 5 3 8 10 7 3 6 2 10 5 9 2 9 8 6 2 4 5 8 10 2 1 9 5 8 8 3 1 8 3 5 3 2 2 8 4 5 9 6 6 10 9 6 7 10 8 6 4 5 9 10 1 5 3 7 10 9 8 6 1 8 9 10 4 7 8 1 4 1 10 8 5 7 5 2 5 10 2 7 7 1 2 6 8 2 3 5 4 2 6 1 4 10 8 9 ...

output:

180962819

result:

ok answer is '180962819'

Test #73:

score: 0
Accepted
time: 10ms
memory: 16256kb

input:

500 10
9 6 4 5 9 7 5 9 6 1 7 7 2 8 9 4 2 4 4 8 10 1 3 7 9 6 4 1 2 6 9 2 3 10 5 7 5 8 9 2 6 4 8 1 4 9 6 7 8 1 7 5 6 5 6 1 3 9 8 8 1 8 10 5 9 10 1 3 10 1 6 9 8 7 3 3 7 8 4 6 7 2 9 1 3 4 5 3 6 1 1 7 8 2 2 6 6 10 9 5 8 8 6 1 7 2 4 7 1 9 4 7 3 3 7 4 10 3 10 8 4 2 5 2 5 7 2 9 4 8 10 8 10 2 4 8 6 2 9 3 2 4...

output:

627406288

result:

ok answer is '627406288'

Test #74:

score: 0
Accepted
time: 14ms
memory: 15024kb

input:

500 10
9 6 3 4 6 5 7 9 9 3 6 6 6 6 7 8 10 10 6 4 4 8 8 10 3 1 5 8 4 9 10 5 5 4 1 8 1 7 4 6 2 4 7 5 2 1 4 5 9 10 1 4 1 1 1 8 5 8 1 4 7 10 7 8 9 9 4 3 4 5 9 4 2 9 10 9 9 6 3 10 7 10 5 8 10 1 6 10 6 2 5 9 8 3 3 9 9 3 5 4 6 8 1 8 3 6 2 4 3 3 7 6 1 9 9 6 5 5 2 3 10 8 6 6 5 10 6 5 1 9 5 10 3 8 10 2 1 9 8 ...

output:

561848920

result:

ok answer is '561848920'

Test #75:

score: 0
Accepted
time: 13ms
memory: 15492kb

input:

500 10
4 8 10 1 1 3 3 4 6 7 10 7 7 3 8 8 3 4 8 2 9 7 3 8 1 4 7 6 4 2 7 8 7 2 9 2 10 3 8 7 3 9 9 6 3 7 2 4 3 4 8 7 2 3 1 9 3 3 9 5 9 2 9 5 1 10 10 3 8 10 2 10 5 9 8 7 8 5 7 3 3 9 9 8 6 4 8 3 9 7 3 3 7 4 10 1 4 4 4 9 3 3 8 5 6 3 8 1 4 4 6 10 4 2 10 3 6 4 5 3 10 10 5 1 3 1 9 6 3 2 10 3 2 7 10 3 9 3 6 7...

output:

762179727

result:

ok answer is '762179727'

Test #76:

score: -100
Wrong Answer
time: 10ms
memory: 14740kb

input:

500 20
18 18 18 2 18 6 2 18 12 6 12 18 18 12 12 6 12 6 6 2 18 12 18 18 18 12 6 18 12 12 6 18 12 18 18 18 6 6 18 18 18 18 6 18 18 18 7 2 12 18 12 18 6 2 18 2 20 12 6 10 18 18 18 18 7 13 18 18 18 12 18 18 18 12 12 18 18 6 12 6 6 7 12 12 18 18 6 8 7 18 18 18 18 12 6 12 7 1 7 18 18 18 18 6 6 18 18 18 18...

output:

820128704

result:

wrong answer expected '537535822', found '820128704'