QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#290566#4051. 学术社区MoRanSky100 ✓959ms48684kbC++236.4kb2023-12-25 05:53:062023-12-25 05:53:07

Judging History

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

  • [2023-12-25 05:53:07]
  • 评测
  • 测评结果:100
  • 用时:959ms
  • 内存:48684kb
  • [2023-12-25 05:53:06]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

#define mp make_pair
#define pb push_back
#define fi first
#define se second

template <typename T> void inline read(T &x) {
	x = 0; int f = 1; char s = getchar();
	while (s < '0' || s > '9') { if (s == '-') { f = -1;} s = getchar(); }
	while (s >= '0' && s <= '9') x = x * 10 + (s ^ 48), s = getchar();
	x *= f;
}

template <typename T> bool inline chkMin(T &x, T y) { return y < x ? x = y, 1 : 0; }
template <typename T> bool inline chkMax(T &x, T y) { return y > x ? x = y, 1 : 0; }

const int N = 77780, M = 77780, S = 15, K = 2 * N, INF = 1e9;

int n, m, len[N], c[M], tp[M], D[M], s, t, in[M], out[M], L[M], R[M];

map<string, int> ID;

char s1[S], s2[S], s3[S];

string inline get(char g[S]) {
	string s = "";
	for (int i = 1; g[i]; i++)
		s += g[i];
	return s;
} 


map<pair<int, int>, vector<int> > MI[2];

void inline apd(int x, int y) {
	R[x] = y, L[y] = x;
}

int q[K], d[K], cur[K], ac[N];

int head[K], numE = 1;

bool ban[M][2];

string O[M], A[M], B[M];

struct E{
	int next, v, w;
} e[M * 8];



set<int> bel[M][2];

int z[M], ar[N], tot;

bool vis[M];

void inline clr() {
	ID.clear();
	for (int i = 1; i <= n; i++) len[i] = 0, bel[i][0].clear(), bel[i][1].clear();
	for (int i = 1; i <= m; i++) L[i] = R[i] = vis[i] = 0, c[i] = tp[i] = ban[i][0] = ban[i][1] = d[i] = 0;
	for (int i = 1; i <= t; i++) head[i] = 0;
	for (int i = 2; i <= numE; i++) 
		e[i].next = e[i].v = e[i].w = 0;
	numE = 1;
	MI[0].clear();
	MI[1].clear();
}

void inline add(int u, int v, int w) {
	e[++numE] = (E) { head[u], v, w };
	head[u] = numE;
}

void inline addE(int u, int v, int w) {
	add(u, v, w), add(v, u, 0);
}

bool inline bfs() {
	for (int i = 1; i <= t; i++) d[i] = 0;
	int hh = 0, tt = 0;
	q[0] = s;
	d[s] = 1; cur[s] = head[s];
	while (hh <= tt) {
		int u = q[hh++]; 
		for (int i = head[u]; i; i = e[i].next) {
			int v = e[i].v;
			if (e[i].w && !d[v]) {
				d[v] = d[u] + 1;
				q[++tt] = v; cur[v] = head[v];
				if (v == t) return 1;
			}
		}
	}
	return 0;
}

int dinic(int u, int flow) {
	if (u == t) return flow;
	int rest = flow;
	for (int i = cur[u]; i && rest; i = e[i].next) {
		int v = e[i].v;
		cur[u] = i;
		if (e[i].w && d[u] + 1 == d[v]) {
			int k = dinic(v, min(rest, e[i].w));
			if (!k) d[v] = 0;
			e[i].w -= k, e[i ^ 1].w += k, rest -= k;
		}
	} 
	return flow - rest;
}

int inline work() {
	int ans = 0, res = 0;
	int zg = 0;
	while (bfs())
		while (res = dinic(s, INF)) ans += res, zg++;
//	cerr << zg << "??\n";
	return ans;
}

int ret[M], ct;

void inline print() {
	tot = 0;
	for (int i = 1; i <= m; i++) {
		if (ban[i][1] && ban[i][0]) continue;
		string o = O[i], a = A[i], b = B[i];
		//cout << o << " " << a << " " << b << endl;
		if (!ban[i][1]) {
			if (o == "loushang" && ID.count(b)) {
				if (e[z[i]].w) {
					ar[++tot] = i;
					bel[c[i]][1].erase(i);
				}
			}
		}

		if (!ban[i][0]) {
			if (o == "louxia" && ID.count(b)) {
				if (e[z[i]].w) {
					ar[++tot] = i;
					bel[c[i]][0].erase(i);
				}
			}
		}	
	}
	for (int i = 1; i <= tot; i++) {
		int u = ar[i], op = tp[u], de = O[u] == "loushang" ? 0 : 1;
		assert(bel[op][de].size());
		int v = *bel[op][de].begin();
		bel[op][de].erase(v);
		if (O[u] == "loushang") {
			apd(u, v); 
		} else apd(v, u);
	}
	for (int i = 1; i <= m; i++) {
		if (!vis[i] && !L[i]) {
			int p = i;
			while (p) {
				vis[p] = 1;
				p = R[p];
			}
		}
	}
	for (int i = 1; i <= m; i++) {
		if (!vis[i]) {
			int p = i;
			while (p && !vis[p]) {
				vis[p] = 1;
				p = R[p];
			}
			int A = i, B = R[i];
			if (O[A] == "loushang") {
				int Bt = ac[c[B]];
				int Tr = L[Bt];
				R[A] = Bt;
				L[Bt] = A;
				if (Tr) R[Tr] = B;
				L[B] = Tr;
			} else {
				int At = ac[c[A]];
				int Tr = R[At];
				R[At] = B, L[B] = At;
				R[A] = Tr;
				if (Tr) L[Tr] = A;
			}
		}
	}
	for (int i = 1; i <= m; i++) vis[i] = 0;
	tot = 0;
	for (int i = 1; i <= m; i++) {
		if (!vis[i] && !L[i]) {
			int p = i;
			while (p) {
				ret[++tot] = p;
				vis[p] = 1;
				p = R[p];
			}
		}
	}
	for (int i = 1; i <= m; i++) printf("%d ", ret[i]);
	puts("");
	int ma = 0;
	for (int i = 1; i < m; i++) {
		int u = ret[i], v = ret[i + 1];
		if (O[u] == "loushang" && tp[u] == c[v]) ma++;
		if (O[v] == "louxia" && tp[v] == c[u]) ma++;
	}
	assert(ma == ct);
}


int main() {
	int T; read(T);
	while (T--) {
		read(n), read(m);
		s = 2 * n + 1, t = 2 * n + 2;
		for (int i = 1; i <= n; i++) {
			in[i] = out[i] = 0;
			scanf("%s", s1 + 1);
			ac[i] = 0;
			len[i] = strlen(s1 + 1);
			string o = "";
			for (int j = 1; s1[j]; j++)
				o += s1[j];
			ID[o] = i;
		}
		ct = 0;
		for (int i = 1; i <= m; i++) {
			scanf("%s%s%s", s1 + 1, s2 + 1, s3 + 1);
			string o = get(s3), a = get(s1), b = get(s2);
			O[i] = o, A[i] = a, B[i] = b;
			c[i] = ID[a];
			if (o == "loushang" && ID.count(b)) {
				tp[i] = ID[b];
				PII F = mp(c[i], tp[i]);
				PII G = mp(tp[i], c[i]);
				D[i] = 1;
				if (MI[1][G].size()) {
					ban[MI[1][G].back()][0] = 1;
					ban[i][1] = 1;
					apd(i, MI[1][G].back());
					MI[1][G].pop_back();
					ct += 2;
				} else MI[0][F].pb(i);
			} else if (o == "louxia" && ID.count(b)) {
				tp[i] = ID[b];
				D[i] = 2;
				PII F = mp(c[i], tp[i]);
				PII G = mp(tp[i], c[i]);
				if (MI[0][G].size()) {
					ban[MI[0][G].back()][1] = 1;
					ban[i][0] = 1;
					apd(MI[0][G].back(), i);
					MI[0][G].pop_back();
					ct += 2;
				} else MI[1][F].pb(i);
			} else {
				ac[c[i]] = i;
			}
		}
//		cerr << n << " " << m << endl;
//		cerr << ct << endl;
		for (int i = 1; i <= m; i++) {
			if (ban[i][1] && ban[i][0]) continue;
			string o = O[i], a = A[i], b = B[i];
			//cout << o << " " << a << " " << b << endl;
			if (!ban[i][1]) {
				bel[c[i]][1].insert(i);
				if (o == "loushang" && ID.count(b)) {
					addE(tp[i] + n, c[i], 1);
					z[i] = numE;
				}
				in[c[i]]++;
				//addE(c[i], t, 1);
			}

			if (!ban[i][0]) {
				bel[c[i]][0].insert(i);
				if (o == "louxia" && ID.count(b)) {
					addE(c[i] + n, tp[i], 1);
					z[i] = numE;
				}
				out[c[i]]++;
				//addE(s, c[i] + n, 1);
			}	
		}
		for (int i = 1; i <= n; i++) {
			if (in[i]) addE(i, t, in[i]);
			if (out[i]) addE(s, i + n, out[i]);
		}
		ct += work();
		printf("%d\n", ct);
		print();
		clr();
	}
}

詳細信息

Test #1:

score: 4
Accepted
time: 3ms
memory: 24312kb

input:

5
7 10
A
B
C
D
E
F
G
A A A
B B B
C C C
D D D
E E E
F F F
G G G
A B loushang
C B loushang
G B loushang
3 10
A
B
C
A A A
B B B
C C C
A B loushang
C B loushang
B A louxia
B A louxia
B C louxia
B C louxia
A C loushang
3 10
A
B
C
A A A
B B B
C C C
A B loushang
A B loushang
B C louxia
B C louxia
A C louxi...

output:

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

result:

ok Correct.

Test #2:

score: 4
Accepted
time: 0ms
memory: 24360kb

input:

10
4 16
A
B
C
D
A abcdefghijkl ABCDEFGHIJKL
B abcdefghijkl ABCDEFGHIJKL
C abcdefghijkl ABCDEFGHIJKL
D abcdefghijkl ABCDEFGHIJKL
C D loushang
C B louxia
B C loushang
D A louxia
B D louxia
A A louxia
D A louxia
C D loushang
D C loushang
B A louxia
B B loushang
A A louxia
4 16
A
B
C
D
A abcdefghijkl AB...

output:

10
1 8 5 4 9 7 6 10 11 12 13 3 15 2 16 14 
12
8 3 11 4 9 12 1 7 14 16 15 10 5 2 6 13 
9
3 8 9 1 10 5 12 6 14 13 4 15 2 16 11 7 
9
3 6 9 5 10 2 11 12 15 13 4 14 1 16 8 7 
7
1 4 5 14 6 7 9 8 11 12 3 13 15 16 2 10 
9
1 15 4 9 2 10 8 11 12 5 13 7 3 14 6 16 
11
2 6 3 13 12 4 11 15 7 1 8 14 16 10 9 5 
9
4...

result:

ok Correct.

Test #3:

score: 4
Accepted
time: 21ms
memory: 25156kb

input:

30
32 153
JpwBq..HDsu
ThevfUaiXaim
rPzLFrkzS!x?
bId_HMvquumA
qIfydwrvFtUF
MEWFHdwhdv
lhPN?!NqYwM
glDverWioFj
XQrJZ?atrx
hpmKvNwWSyhm
!KyWsTyVYf
wbhBWyPFh.N
PSsASTqBzE
mLCSCCLz.O
t.mbBELmCr
r.I!!?VCwnJQ
I?u!__ObGu
?_WyipVJj_c
cLDIkTYgonB
RUklAjWZ!.om
WRXWhpWD.g
JNqhVkbJ_g
HxpqMsUj!XOV
WvkzijbZb!D
!wy...

output:

121
1 40 32 46 9 27 86 41 59 31 6 8 36 75 48 68 112 80 98 122 118 95 132 141 137 96 12 107 124 15 66 61 19 20 23 30 93 134 33 65 58 52 10 28 54 25 55 13 2 5 22 35 34 18 14 24 57 17 43 101 37 42 44 125 45 91 142 153 49 50 76 73 63 38 47 85 126 119 121 146 56 51 90 115 144 67 103 135 120 69 82 105 106...

result:

ok Correct.

Test #4:

score: 4
Accepted
time: 20ms
memory: 26024kb

input:

30
32 165
cOrq.aXFlS
hhUwqwEhbR
STbfehzpg_
.pEbZEBQ!CJ
!ZrjAUDsFKIV
DxAYVmTQHlG
mdehhvitnCx
Znc.cGD.dy
.rgMqdJwB.H
oDxVlF?.wxW
bxF_qUlnMs
dvhzBd?WJL
hbDuYRbJQpHF
YJfupPIUzJtk
mUR!I?Exxr
csFCwfWNkd_s
dcAMbqtmnYDA
FyE.mDdgzC
uYpIamtkCVR
dPQgKFgYZP
tTl!ExnlcY
oVNrqKw?.A
gigkZHizGX
dSoVEtHSEhWw
QhoSFhcs...

output:

133
6 13 68 15 10 62 103 127 152 18 21 75 109 144 19 23 78 34 38 120 161 159 151 35 96 110 134 80 94 81 104 39 26 157 43 154 147 53 16 24 5 1 25 57 112 122 136 61 66 30 27 76 64 87 126 153 69 125 56 54 67 124 72 143 149 93 83 129 79 107 101 45 121 82 86 137 70 74 89 133 44 73 60 58 28 9 7 32 84 123 ...

result:

ok Correct.

Test #5:

score: 4
Accepted
time: 21ms
memory: 26952kb

input:

30
37 174
iGtEwpQ?kqZO
OZqk?QpwEtGq
OZqk?QpwEtG?
jGtEwpQ?kqZO
OZqk?QpwEtGu
OZqk?QpwEtGO
IGtEwpQ?kqZO
OZqk?QpwEtGw
SGtEwpQ?kqZO
BGtEwpQ?kqZO
OZqk?QpwEtGb
oGtEwpQ?kqZO
KGtEwpQ?kqZO
XGtEwpQ?kqZO
UGtEwpQ?kqZO
nGtEwpQ?kqZO
OZqk?QpwEtGp
lGtEwpQ?kqZO
OZqk?QpwEtGg
_GtEwpQ?kqZO
OZqk?QpwEtGY
OZqk?QpwEtGr
OZqk...

output:

110
2 6 27 103 7 12 118 14 41 122 15 5 82 16 17 64 18 101 20 8 77 99 86 161 173 21 91 22 95 31 13 29 30 28 67 72 162 35 37 89 69 38 46 85 40 150 109 116 100 144 44 52 24 78 39 45 9 19 32 43 139 172 121 120 104 48 11 114 107 49 71 157 169 111 50 51 26 34 129 119 56 133 59 125 113 58 151 130 135 154 1...

result:

ok Correct.

Test #6:

score: 4
Accepted
time: 20ms
memory: 25192kb

input:

30
28 163
BzleygJkKK
gdGiNNA?k.
qglX_GEvVWd
cIpmqbJIAC!U
q_MotjTfNX
YrTvPGRTKbnW
jrzBmcBQsw
t.jM.YxMYD
dqOpPkNmBT
fCGQHr!vYf
PZrGVRcDdUz
kklKFtFFNqP
GHcfKydBiHTj
weFZpvkQlQ
lJhGmiBGtLlh
K!?qmzmYiu
SUbVc.PiSU
GoqemRLiXXs
VVMdGHbtSN
AcJhbRhURKW
JNwhBUZxSRk
wLzONCLeyAE
myyaktsMhEH
SVwzBQQh.GCi
kNxhFcjW...

output:

126
5 9 1 22 68 157 11 7 87 89 54 41 33 63 99 55 125 17 80 123 107 139 111 114 127 163 160 13 6 39 153 16 2 67 66 94 134 19 102 122 27 26 73 28 53 82 150 161 30 3 58 64 84 43 14 37 57 47 71 129 118 36 15 85 130 95 158 103 38 29 24 20 23 40 12 133 44 56 106 143 18 52 120 46 72 92 101 49 132 50 51 62 ...

result:

ok Correct.

Test #7:

score: 4
Accepted
time: 21ms
memory: 25212kb

input:

30
32 168
fj_yTpB_YcEv
!j_yTpB_YcEv
vEcY_BpTy_js
vEcY_BpTy_jg
Kj_yTpB_YcEv
Uj_yTpB_YcEv
vEcY_BpTy_jP
mj_yTpB_YcEv
vEcY_BpTy_ju
Zj_yTpB_YcEv
vEcY_BpTy_jv
Tj_yTpB_YcEv
bj_yTpB_YcEv
pj_yTpB_YcEv
vEcY_BpTy_ji
vEcY_BpTy_jF
.j_yTpB_YcEv
Yj_yTpB_YcEv
Aj_yTpB_YcEv
zj_yTpB_YcEv
vEcY_BpTy_jt
vEcY_BpTy_jX
vEcY...

output:

136
1 19 27 87 61 30 12 13 35 43 72 21 36 38 20 137 149 22 9 23 8 73 62 74 33 70 104 84 108 145 77 85 52 53 150 91 117 110 31 34 83 45 56 113 114 128 116 54 63 118 143 165 107 131 88 119 158 140 97 18 112 80 120 121 122 32 11 58 48 50 49 6 5 134 125 78 135 79 64 51 138 133 147 94 129 139 46 42 146 1...

result:

ok Correct.

Test #8:

score: 4
Accepted
time: 22ms
memory: 25252kb

input:

30
32 168
OFBjSz_NqA
vFz!ZTNzIR
nljJhG!ro_
N!EqwUCFSIO
.lkTtUQuz_
rlkrtassDAu
EiqqUh?uNW
UrqRdKMSWCKi
aoeFwQvoftO
CXFPwk_AP.Sj
LXcKqfiasOQ
iEGWfwPkvDHt
AMIAlbc?giw
zDOWiTF!KQG
flUCnUqcPwh
EHsxJUvQgm
ueCDm_SlwA
TsnKKyLOqv
vZjVxrc!PDg
hQHuHuqfcqa
aDBXqENPORBX
uspFeYobvOe
WHdCXSApc.kQ
vqbyBV?!IL
NixXod...

output:

136
18 38 9 101 40 46 164 76 27 44 68 70 75 144 90 118 165 78 26 85 63 49 88 95 52 96 102 53 69 105 86 120 110 71 48 32 72 109 115 12 19 117 159 121 122 123 125 133 130 59 66 136 31 14 114 138 83 82 61 39 4 24 129 113 149 141 100 80 13 21 35 108 142 58 20 3 60 47 94 33 161 147 143 29 67 73 16 17 10 ...

result:

ok Correct.

Test #9:

score: 4
Accepted
time: 23ms
memory: 25908kb

input:

30
296 2195
K!YyGhp!Gl.Y
lFLYZGmNLy
pVAZuRySnD!g
RwwPPFcLMG
_QNQsvJNqhkZ
bslmJT.yuL
wOWjJfHqkD
yYAnD!pqJtP
pdjijhpxvX
Hk_IiwGCjV
eebSCJnHyd
LFMtXMAasMB
VYbnctPAg?
YDuIpaoDTEBY
de??KzSim_ub
VRVAGbwJYLl
.s?BbsCNWj
IHOaqvdxsx
DncVyohjab
aQQMMijXpBSi
rVxMTXneoFm
?HJXsmbXH?v.
c.KrBqwh?sI
kLoczbNPmMue
oat...

output:

1898
42 1687 948 1454 1648 685 2078 58 1503 1969 1858 2151 85 138 932 830 1672 228 270 277 87 201 377 579 384 160 82 180 263 351 319 550 170 2008 1635 1659 182 1764 1124 1505 1822 330 295 1600 1087 341 409 498 17 289 882 335 617 931 1343 995 1713 438 1365 711 1031 1022 1547 445 1329 1912 449 814 107...

result:

ok Correct.

Test #10:

score: 4
Accepted
time: 19ms
memory: 24992kb

input:

30
34 149
TfqnSAOpxRq
DtwPJm.ghzkO
hHdCRvQJG.At
l.WQg.v!yICt
nHPzIZPy!zoJ
.WKOXmnLvGmK
p_MM.vADQk
_EswrdFyyoaf
zrcIzTuVJtN
OfpWwS!byAky
pEEmid?xVi
ueim_rfLdR.?
cHZv!fwIlef
VVozgCXwdX?
WgMZxRVMhQB
YErodqcTkpKS
tc!vNbsHiQh
blDcRTRsek
XmwLFhGPCyx
nOs!R_M?YQ
vzSo!rChKHw
QwhkNQRkFsw
gjVWRcGOBs
XQFgcwJVnl...

output:

107
5 10 20 6 1 9 23 32 43 27 87 36 39 60 76 25 69 51 61 7 42 44 117 72 123 45 8 48 21 26 83 101 127 100 13 71 34 4 144 67 38 68 91 95 70 73 47 29 28 74 77 62 17 75 80 63 66 107 82 96 97 104 106 58 50 110 111 112 33 16 81 113 115 99 90 132 116 128 84 136 124 114 30 15 102 119 78 98 105 52 118 65 53 ...

result:

ok Correct.

Test #11:

score: 4
Accepted
time: 23ms
memory: 25892kb

input:

30
39 181
BEiCGrRPmHFM
?FHmPRrGCiEB
oFHmPRrGCiEB
YFHmPRrGCiEB
BEiCGrRPmHF_
BEiCGrRPmHFp
lFHmPRrGCiEB
BEiCGrRPmHFD
BEiCGrRPmHFB
BEiCGrRPmHFC
BEiCGrRPmHFP
dFHmPRrGCiEB
BEiCGrRPmHFO
hFHmPRrGCiEB
zFHmPRrGCiEB
FFHmPRrGCiEB
EFHmPRrGCiEB
AFHmPRrGCiEB
yFHmPRrGCiEB
BEiCGrRPmHFx
BEiCGrRPmHFf
BEiCGrRPmHFJ
BEiC...

output:

131
3 84 83 160 167 13 17 50 4 1 99 60 6 128 53 37 80 107 24 34 30 44 136 124 45 41 33 166 55 43 31 5 64 9 72 58 101 49 106 65 29 27 90 68 62 97 59 74 76 165 169 178 78 14 79 36 85 86 121 91 75 67 92 100 102 120 12 38 11 28 96 10 15 47 39 117 105 70 152 132 109 111 135 112 119 20 8 171 113 56 61 46 ...

result:

ok Correct.

Test #12:

score: 4
Accepted
time: 20ms
memory: 24840kb

input:

30
299 2221
CUscRFl!Y!
!NGeGkkgqKf
mxi?xcEjAvY
vRLSjVAwyTf
Jos!CsOJWaHA
juLYYH_hPzZu
yrj?Gt!MQCO
YiWC!TgjaH?O
?uAUKATuTbvu
RfbOyy!UAzWx
qRvLUZDtC!C
piCrwPLEMDku
qSQXXWYnxz
hGM?ik.gGSfe
Z!PEbb_wOuGN
sXtTcp.Uwy
lD_RWWL.ylme
lxsAAozRfq.
iWBBxQsHYKN!
COHBMlBwf_Y
pHOGeB_xhb
wIRf?npomha
fKdzbGojyeGq
mkbSh...

output:

1865
2 19 882 229 602 1038 1628 20 39 53 59 504 1927 1758 69 70 78 79 102 42 1708 131 132 137 812 1908 864 1837 1337 141 2221 159 74 1615 162 1445 1959 1600 177 194 498 1644 257 372 1538 2071 1852 1905 1121 572 89 101 412 145 594 1514 268 278 187 296 596 877 298 299 300 323 386 262 326 107 241 32 21...

result:

ok Correct.

Test #13:

score: 4
Accepted
time: 21ms
memory: 24848kb

input:

30
296 2191
.ls.paaIC.
vwPSDMubAA
PQjPGeOVesYQ
amhPAxTDcS
YHIYufo!Xk
PHp.ywUjrmaJ
PCZpBhINrsn
f?IOYZQ_RxM
uaitSaXHImn
SXPuuMuNbe
JfTEZmKXz?Q?
ypPKDcvi?L
HjoMtljhh_K?
mCSC?mrCppda
EYGtMXxhSXM
PNrrHyLFxGA
xFuxXBejBJDS
EIOYSBujnCu
.fqXVRnkkgdD
dXJtWg!DywME
?JvpnsbWCFk
ffYukXaAnJL
ytMQvDFSBkEn
zYZItVPDs...

output:

1842
6 38 59 73 78 118 123 124 133 138 145 160 19 2143 200 205 212 2012 215 217 377 164 33 63 155 1467 221 686 1374 223 225 227 275 969 1346 230 87 394 161 95 1205 1889 233 255 269 276 280 508 291 743 745 680 156 669 1197 1222 283 290 1856 297 301 309 314 315 392 1550 336 343 349 353 385 387 228 432...

result:

ok Correct.

Test #14:

score: 4
Accepted
time: 677ms
memory: 48684kb

input:

100
37 229
fMbXOgQT.YC?
fMbXOgQT.YCA
fMbXOgQT.YCq
fMbXOgQT.YC!
fMbXOgQT.YCL
fCY.TQgOXbMf
fMbXOgQT.YCi
VCY.TQgOXbMf
fMbXOgQT.YCE
fMbXOgQT.YCW
gCY.TQgOXbMf
eCY.TQgOXbMf
fMbXOgQT.YCj
fMbXOgQT.YCZ
UCY.TQgOXbMf
fMbXOgQT.YCz
fMbXOgQT.YCv
fMbXOgQT.YCk
wCY.TQgOXbMf
.CY.TQgOXbMf
YCY.TQgOXbMf
fMbXOgQT.YCc
fMb...

output:

192
8 21 6 46 48 47 45 13 54 24 133 132 115 127 106 212 199 219 9 80 63 122 60 50 5 12 10 1 73 112 53 67 18 31 4 100 59 101 37 78 25 107 177 26 41 91 64 19 93 98 141 28 65 218 30 117 144 163 188 162 183 176 32 29 82 44 14 103 126 168 160 187 49 109 125 215 56 206 61 68 11 79 51 191 155 131 86 99 196...

result:

ok Correct.

Test #15:

score: 4
Accepted
time: 692ms
memory: 45996kb

input:

100
40 257
gE?fFSdapGwW
WwGpadSFf?Er
QE?fFSdapGwW
KE?fFSdapGwW
WwGpadSFf?EA
WwGpadSFf?Ev
lE?fFSdapGwW
cE?fFSdapGwW
WwGpadSFf?Ei
GE?fFSdapGwW
HE?fFSdapGwW
WwGpadSFf?Eq
zE?fFSdapGwW
WwGpadSFf?EL
dE?fFSdapGwW
WwGpadSFf?En
WwGpadSFf?Ee
aE?fFSdapGwW
WwGpadSFf?Eu
SE?fFSdapGwW
WwGpadSFf?Ef
WwGpadSFf?EF
?E?...

output:

217
20 16 39 85 173 30 71 112 163 169 251 32 62 133 78 139 46 152 257 244 192 241 156 172 221 34 43 38 36 13 22 96 181 235 47 190 48 106 57 44 117 199 217 211 63 18 146 119 208 83 113 178 175 165 24 52 110 193 218 64 21 49 54 56 37 59 127 67 51 81 107 232 246 65 108 35 120 33 111 234 70 69 90 224 76...

result:

ok Correct.

Test #16:

score: 4
Accepted
time: 706ms
memory: 47016kb

input:

100
48 235
rQwzIJIECH.
sHIrfxcFOzh?
fjyfN.VfyUc_
cqSJbkhGnvN
zQ_YiZJQG!p
dpB_yEOtYMsP
tZ!DgibUTCom
X!VbNNtjqAG
TVDBRrRK!Kg
ngRjPukiMgB
puuuHN.BdW
syI.!_kjVod
swGUueBxJkfC
PWpOzFkSjvB
IuRjFJwLeef
HrGDcoptd_L
uDqKFgRRbic
kDVinBwAyTe
!m?tIqISxLG
KweFXtM_XNSv
nlRYoYgiI!
_lo!z_rHy.T
.pErbUIEMAE
.RMMgrxez...

output:

166
1 53 94 77 88 193 215 182 2 15 19 8 37 99 47 17 5 14 162 167 86 135 66 103 226 3 33 223 6 27 65 4 23 201 13 20 58 35 16 130 24 34 157 84 56 221 183 125 187 25 109 151 217 26 64 18 28 95 55 173 158 101 76 32 39 44 38 212 51 116 110 195 232 54 57 213 120 180 59 50 75 129 197 69 108 72 83 85 188 91...

result:

ok Correct.

Test #17:

score: 4
Accepted
time: 689ms
memory: 46796kb

input:

100
49 231
hTKBowtR?xxV
CTKBowtR?xxV
jTKBowtR?xxV
tTKBowtR?xxV
fTKBowtR?xxV
yTKBowtR?xxV
Vxx?RtwoBKTe
Vxx?RtwoBKTp
Vxx?RtwoBKTJ
Vxx?RtwoBKTu
Vxx?RtwoBKTS
XTKBowtR?xxV
Vxx?RtwoBKTs
NTKBowtR?xxV
Vxx?RtwoBKTr
ZTKBowtR?xxV
BTKBowtR?xxV
ITKBowtR?xxV
DTKBowtR?xxV
Vxx?RtwoBKTE
Vxx?RtwoBKTM
Vxx?RtwoBKTL
UTK...

output:

182
9 21 54 63 42 19 221 59 151 13 104 135 17 101 168 127 69 70 2 60 177 78 86 91 14 61 142 193 203 64 194 96 116 144 25 75 125 83 38 31 30 50 103 40 3 28 97 106 152 217 107 115 118 117 39 180 124 133 136 154 122 98 166 167 130 172 202 138 102 6 12 71 81 146 82 201 149 159 123 153 150 158 161 73 132...

result:

ok Correct.

Test #18:

score: 4
Accepted
time: 685ms
memory: 46544kb

input:

100
38 256
ZARmlFP!BuNE
ENuB!PFlmRAv
tARmlFP!BuNE
ENuB!PFlmRAC
YARmlFP!BuNE
ENuB!PFlmRAN
EARmlFP!BuNE
JARmlFP!BuNE
zARmlFP!BuNE
ENuB!PFlmRAj
ENuB!PFlmRAg
rARmlFP!BuNE
BARmlFP!BuNE
sARmlFP!BuNE
oARmlFP!BuNE
mARmlFP!BuNE
WARmlFP!BuNE
eARmlFP!BuNE
ENuB!PFlmRAQ
ENuB!PFlmRAP
bARmlFP!BuNE
.ARmlFP!BuNE
ENu...

output:

218
18 184 237 81 31 115 84 99 173 51 76 82 38 24 14 2 69 95 85 177 233 228 104 120 4 136 253 129 39 91 97 174 172 216 225 122 135 139 142 147 236 55 23 103 65 200 149 77 17 50 28 90 133 7 30 73 160 246 153 119 150 168 138 62 59 165 170 11 54 89 118 171 46 107 72 121 68 93 114 182 214 74 36 5 109 49...

result:

ok Correct.

Test #19:

score: 4
Accepted
time: 682ms
memory: 48572kb

input:

100
42 222
jmkootSXiZ
mWhoHNURiY
VUseF.Y_KAr
zedzeXFnSV!h
MugQz?bXs?n
nxgnJZzbKZ
xP.ZFX!NG_T
mwut_dUUIIpe
P?YgAA.tHx
.ksdRBEDMVGR
J_iwVZXqVEN
MvsELmrvjrT
FuAsbulWTe
LDAUkkWmlT
KsdSADmwm.CQ
qzbLzm?IOhl
jLxpYahEXS
gAybIDI_VYi
jXasQbfNRnIA
o.YWEoULQMZ
hTMhqSnvFOWG
t?QEczqaYklA
PiaiBu_NPJt
Ezvig.in?G
AR...

output:

180
1 4 8 20 30 37 41 66 146 209 215 220 86 147 7 5 12 64 47 115 140 164 78 18 54 15 119 132 89 91 93 88 90 67 51 107 111 118 61 50 14 9 35 82 142 128 106 124 196 76 219 129 130 121 135 113 45 11 16 34 79 126 98 116 194 149 60 92 40 68 31 100 148 13 70 160 161 125 102 141 185 84 163 184 138 101 180 ...

result:

ok Correct.

Test #20:

score: 4
Accepted
time: 912ms
memory: 46892kb

input:

100
32 236
gDBkQygRmXGf
DzgosmXBRL
DPpicDZAFlF
CULmbsr.etf
nFIxBkPYhE
DLQpMlVoPBr
HLfkkADNASFD
LTWrUNjcIn
Nrj.Ls?aeKOJ
DYw_hgITGW
wsbpKIIMN_o
BoxPjqJ.Ps
SkvDAnf..dvE
RMkisXjf_QSk
wKVFtHFaG_
XzGGA_S!NZ?H
FzpdxTWnb_G
gsYVmejwPcqi
mOoWwJuxhUKD
lyfoCxJNbt
CFPGpsdmsvf
HdrBp?bUWQkH
sJpwIYuYevZ
NbpVpB.foE
...

output:

182
2 3 30 135 41 22 13 36 71 6 56 29 111 57 138 207 62 213 72 87 189 192 91 130 142 173 98 150 99 209 100 49 45 9 113 219 115 17 121 67 140 234 131 136 35 10 47 144 133 84 31 199 134 18 19 39 44 112 218 141 171 154 143 146 125 86 195 148 80 156 82 117 162 155 127 163 151 116 79 128 60 43 40 89 164 ...

result:

ok Correct.

Test #21:

score: 4
Accepted
time: 941ms
memory: 47320kb

input:

100
41 251
AKyUZjS!HCog
goCH!SjZUyKI
CKyUZjS!HCog
tKyUZjS!HCog
goCH!SjZUyK_
PKyUZjS!HCog
TKyUZjS!HCog
goCH!SjZUyK!
rKyUZjS!HCog
goCH!SjZUyKX
hKyUZjS!HCog
LKyUZjS!HCog
sKyUZjS!HCog
MKyUZjS!HCog
iKyUZjS!HCog
goCH!SjZUyKS
kKyUZjS!HCog
goCH!SjZUyKQ
GKyUZjS!HCog
EKyUZjS!HCog
RKyUZjS!HCog
eKyUZjS!HCog
qKy...

output:

197
3 28 23 173 204 184 209 31 43 240 5 56 163 207 32 39 159 61 49 48 65 58 93 69 57 151 51 40 15 98 10 203 53 11 14 79 54 33 170 105 101 128 76 231 60 82 75 242 171 83 90 4 6 24 67 97 66 68 123 120 94 154 125 180 156 196 114 95 150 126 102 107 89 115 109 142 35 25 78 241 222 111 117 119 118 80 74 1...

result:

ok Correct.

Test #22:

score: 4
Accepted
time: 959ms
memory: 46564kb

input:

100
47 262
NUgKTQWLqlSu
J_UepZVpZI!
OFybuzA.ts
aJ!oeiupGpt
qEgiXBlraO
G.InLDNYalJ
IKqd?LBbOcS
fGfB.YSKA?
HkgFU.G_FGZ!
QVUDexUYhPt
yVKXraeLEjz
uBNttpsXtQew
_rh_WoubMp
dBmNlhaKQK
rcDEYYtaeF
..wusKVgmxn
jSyLVgt_CkL
GxAwCFvGADS
EszfFlNthk_
EcxJBVUIZw
WrbZ_qvBHIUq
bTgeRogA_oAF
Xr!ELlblATX
zOvG!alEcx
vtrG...

output:

197
6 18 126 35 114 198 19 38 81 94 20 27 29 54 22 30 33 100 152 34 47 52 70 91 95 72 88 42 71 102 103 151 147 106 172 83 86 170 84 214 120 175 112 238 257 124 14 10 13 239 116 248 218 128 3 51 101 149 129 134 131 234 235 138 28 123 40 36 16 49 171 93 201 143 144 15 206 153 60 80 73 45 155 68 133 50...

result:

ok Correct.

Test #23:

score: 4
Accepted
time: 771ms
memory: 44844kb

input:

100
44 263
GSwTGPndPrW
fQ_HniYihylp
zeLunnprU.
!Xx?xCWdZaS
yfQrY!laHT
xRHVh.bwwOxY
rZTEYbwQeiW
kdBlS_?iWW
bPVYVCLdjgkw
cheZRqcCFAN
tXFglACkIog
lnqlbAnTByp
wlTUrKRxXAGt
jORjpjqnt.
damueIrdQY
RANWBksGZZdd
CucYTniEj.M
ueLzXFh?TV
RqKArM?pZo
ozu!_Vtkrx
QqbuBOLfGc
sTRTdSKbkZLz
od_yHkJZXmt
efyCIFkzMdP
OMDG...

output:

209
19 112 16 139 33 93 17 38 166 39 35 104 73 59 52 42 225 44 69 98 113 47 90 53 106 25 9 56 41 215 54 64 57 67 70 76 86 201 80 49 58 11 140 121 72 110 2 84 160 82 1 50 141 92 105 88 107 221 145 114 32 109 122 169 87 123 51 55 237 250 125 68 34 20 163 131 128 133 245 103 134 13 135 138 115 183 142 ...

result:

ok Correct.

Test #24:

score: 4
Accepted
time: 787ms
memory: 45604kb

input:

100
45 248
zJwHpe_rlmeC
zJwHpe_rlmex
Memlr_epHwJz
temlr_epHwJz
oemlr_epHwJz
uemlr_epHwJz
zJwHpe_rlmeR
zJwHpe_rlmee
zJwHpe_rlmeQ
gemlr_epHwJz
demlr_epHwJz
zJwHpe_rlmea
zJwHpe_rlmeB
Yemlr_epHwJz
Eemlr_epHwJz
remlr_epHwJz
zJwHpe_rlmeA
zJwHpe_rlmew
zJwHpe_rlmei
zJwHpe_rlmeU
zJwHpe_rlmeS
Lemlr_epHwJz
Pem...

output:

200
4 54 17 9 8 83 13 127 34 132 16 21 39 194 44 49 24 68 47 116 51 52 70 55 77 71 78 123 79 230 85 86 60 87 122 88 25 42 31 35 236 90 134 135 165 38 91 72 157 231 94 146 99 1 27 22 12 23 56 233 102 101 130 162 57 108 98 18 241 111 113 109 143 58 73 3 45 119 105 65 181 225 167 118 200 124 107 121 22...

result:

ok Correct.

Test #25:

score: 4
Accepted
time: 762ms
memory: 46812kb

input:

100
49 294
XffSYEnSOVF
h.UQkRgrjER
PJOu?WVkaF
QwuvOKStQV
yEw_.VGRFoin
GxnGO.hEZh
fDTLxVKNobB
bYPNHVjs_SG
WgbSzRKxbhH
u.py_GkcRyk
WwDZdqsFLO
ZSJQMjyCVDc
JlaAWop.Lv_
PpZZ!Bqveo
kGGEbPCmDqUB
STUKjUFmfqV
lLJY!jzeCOl_
SBlmMsHDMh
FIkInhGMhe
Oymidks!bYY
rptc!EVznL!
fXXggRKsa!RT
CCeQkacXRA!
.IKFMJTtrLW
EpbE...

output:

230
4 3 187 5 13 106 183 16 20 17 30 23 222 40 67 248 241 41 43 137 52 57 6 22 76 55 86 228 61 88 85 211 63 112 68 77 136 105 64 207 79 83 213 217 74 221 117 94 21 24 59 216 285 96 97 132 173 71 100 170 103 101 26 8 9 195 283 104 51 34 73 178 274 107 78 197 246 109 208 259 115 28 27 58 90 118 194 10...

result:

ok Correct.

Extra Test:

score: 0
Extra Test Passed