QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#31634#1874. Goldberg Machine 2cdwAC ✓2165ms64504kbC++204.4kb2022-05-10 20:31:362022-05-10 20:31:38

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-10 20:31:38]
  • 评测
  • 测评结果:AC
  • 用时:2165ms
  • 内存:64504kb
  • [2022-05-10 20:31:36]
  • 提交

answer

#include<bits/stdc++.h>
const int N = 103, B = 30, lim = (1<<B)-1, L = 1e9, K = 30;
typedef long long LL;
std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int n, m, q;
std::string s[2][N];
void clr(std::vector<LL> &a){while(!a.empty() && !a.back()) a.pop_back();}
struct bigD : public std::vector<LL> {using vector<LL>::vector;} T[K][N][N], A[K][N][N], half, dt[K];
bigD operator + (const bigD &a, const bigD &b){
	bigD res(std::max(a.size(), b.size()));
	for(int i = (int)res.size()-1;i >= 0;-- i){
		res[i] += (i < a.size() ? a[i] : 0) + (i < b.size() ? b[i] : 0);
		if(res[i] > lim){res[i] &= lim; if(i) ++res[i-1];}
	}
	clr(res); return res;
}
bigD operator - (bigD a){
	if(a.empty()) return a;
	a.back() = (-a.back()) & lim;
	for(int i = 0;i+1 < a.size();++ i) a[i] ^= lim;
	return a;
}
bigD operator - (const bigD &a, const bigD &b){return a + (-b);}
bigD operator * (const bigD &a, const bigD &b){
	if(a.empty() || b.empty()) return {};
	bigD res(a.size() + b.size());
	for(int i = 0;i < a.size();++ i)
		for(int j = 0;j < b.size();++ j)
			res[i+j+1] += a[i] * b[j];
	for(int i = (int)res.size()-1;i >= 0;-- i){
		if(i) res[i-1] += (res[i] >> B);
		res[i] &= lim;
	}
	clr(res); return res;
}
int len(const bigD &a){return a.empty() ? 0 : B * a.size() - __builtin_ctzll(a.back());}
bigD operator << (const bigD &a, int sh){
	int bl = sh / B, rem = sh % B;
	bigD res(a.size());
	if(bl < a.size()) res[0] = a[bl] << rem & lim;
	for(int i = bl+1;i < a.size();++ i){
		res[i-bl] |= a[i] << rem & lim;
		res[i-bl-1] |= a[i] >> B - rem;
	}
	clr(res); return res;
}
bigD operator >> (const bigD &a, int sh){
	int bl = sh / B, rem = sh % B;
	bigD res(a.size() + bl + 1);
	for(int i = 0;i < a.size();++ i){
		res[i+bl] |= a[i] >> rem;
		res[i+bl+1] |= (a[i] << B - rem) & lim;
	}
	clr(res); return res;
}
bigD inv(bigD a){
	bigD res = a; int bt = len(a);
	for(int i = 0;i < bt-2;++ i){
		a = a * a << bt;
		res = res * a << bt;
	}
	clr(res); return res;
}
struct bigI : public std::vector<LL> {using vector<LL>::vector;};
bigI operator + (const bigI &a, LL coe){
	bigI res(a.size() + 1); res[0] = coe;
	for(int i = 0;i < res.size();++ i){
		if(i < a.size()) res[i] += a[i];
		res[i+1] += res[i] / L; res[i] %= L;
	}
	clr(res); return res;
}
bigI operator * (const bigI &a, LL coe){
	bigI res(a.size() + 3);
	for(int i = 0;i < res.size();++ i){
		if(i < a.size()) res[i] += a[i] * coe;
		res[i+1] += res[i] / L; res[i] %= L;
	}
	clr(res); return res;
}
bigI getnum(const bigD &a, int L = -1){
	if(L == -1) L = len(a);
	bigI res; int rem = L % B;
	for(int i = 0;i < L / B;++ i) res = res * (1 << B) + (i < a.size() ? a[i] : 0);
	res = res * (1 << rem) + (L / B < a.size() ? (a[L / B] >> B - rem) : 0);
	clr(res); return res;
}
std::ostream &operator << (std::ostream &out, const bigI &a){
	if(a.empty()) return out << 0;
	out << a.back();
	for(int i = (int)a.size() - 2;~i;-- i) out << std::setfill('0') << std::setw(9) << a[i];
	return out;
}
void work(int id){
	auto t = T[id], a = A[id];
	for(int i = n-1;i >= 0;-- i)
		for(int j = m-1;j >= 0;-- j) if(s[0][i][j] != '.'){
			bigD right = t[i][j+1] >> 1, down = t[i+1][j] >> 1;
			t[i][j] = right + down;
			a[i][j] = right - down;
			if(rng() & 1){
				t[i][j] = t[i][j] + half;
				a[i][j] = a[i][j] + half;
			}
		}
}
int main(){
	std::ios::sync_with_stdio(false);
	half.push_back(1 << B - 1);
	std::cin >> n >> m >> q;
	for(int i = 0;i < 2;++ i)
		for(int j = 0;j < n;++ j)
			std::cin >> s[i][j];
	int L = 0;
	for(int id = 0;id < K;++ id){
		work(id);
		L = std::max(L, len(T[id][0][0]));
	}
	for(int id = 0;id < K;++ id){
		while(len(T[id][0][0]) < L) work(id);
		bigD tmp = inv(T[id][0][0]);
		for(int i = 0;i < n;++ i)
			for(int j = 0;j < m;++ j){
				A[id][i][j] = A[id][i][j] * tmp << L;
				if(s[0][i][j] == '>') dt[id] = dt[id] + A[id][i][j];
				if(s[1][i][j] == '>') dt[id] = dt[id] - A[id][i][j];
			}
	}
	auto solve = [&](){
		bool flg = true;
		for(int i = 1;i < K && flg;++ i) flg &= dt[i] == dt[0];
		if(flg) std::cout << getnum(min(dt[0], -dt[0]), L) << '\n';
		else std::cout << "-1\n";
	};
	solve();
	while(q --){
		int op, r, c;
		std::cin >> op >> r >> c;
		-- op; -- r; -- c;
		bool flg = op ^ (s[op][r][c] == 'v');
		s[op][r][c] ^= '>' ^ 'v';
		for(int id = 0;id < K;++ id)
			dt[id] = flg ? dt[id] + A[id][r][c] : dt[id] - A[id][r][c];
		solve();
	}
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 18528kb

input:

3 3 9
>v>
vv>
v.>

v>>
v>>
v.>

2 3 1
2 2 1
2 1 1
1 3 3
1 2 2
2 3 3
2 3 1
1 1 2
1 2 1

output:

1
-1
-1
2
14
-1
-1
-1
-1
0

result:

ok 10 tokens

Test #2:

score: 0
Accepted
time: 607ms
memory: 18604kb

input:

1 1 100000
v

v

1 1 1
2 1 1
2 1 1
1 1 1
2 1 1
2 1 1
1 1 1
1 1 1
2 1 1
2 1 1
2 1 1
1 1 1
1 1 1
1 1 1
2 1 1
1 1 1
2 1 1
2 1 1
1 1 1
1 1 1
1 1 1
1 1 1
2 1 1
1 1 1
1 1 1
2 1 1
2 1 1
2 1 1
2 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
2 1 1
2 1 1
1 1 1
1 1 1
2 1 1
1 1 1
2 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
2...

output:

0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
...

result:

ok 100001 tokens

Test #3:

score: 0
Accepted
time: 517ms
memory: 18672kb

input:

2 2 100000
>v
v>

>>
>v

2 1 1
1 1 1
2 1 1
1 1 1
2 2 2
1 2 2
2 1 2
2 1 1
2 1 2
1 1 2
1 2 2
2 2 2
1 2 2
2 2 2
1 1 2
2 1 2
2 1 1
2 2 2
2 2 1
1 1 1
2 1 1
2 2 2
2 2 1
2 1 2
2 1 1
2 2 2
2 2 1
1 1 1
1 2 1
2 2 2
1 2 2
1 1 1
1 1 2
1 2 2
1 2 2
2 2 2
2 1 2
1 1 2
1 2 2
2 2 2
2 1 2
1 2 2
1 2 1
1 2 1
2 2 1
2 1 2...

output:

2
-1
2
-1
2
-1
2
-1
1
-1
1
-1
1
-1
1
-1
1
-1
-1
0
-1
0
-1
-1
2
-1
-1
1
-1
2
-1
2
-1
-1
1
-1
1
-1
1
-1
1
-1
-1
1
-1
1
-1
0
-1
0
-1
-1
1
-1
1
-1
-1
2
-1
2
-1
1
-1
1
-1
1
-1
0
-1
-1
1
-1
-1
0
-1
0
-1
0
-1
-1
2
-1
1
-1
2
-1
-1
2
-1
2
-1
2
-1
2
-1
-1
1
-1
1
-1
-1
2
-1
2
-1
2
-1
2
-1
-1
2
-1
2
-1
2
-1
-1
...

result:

ok 100001 tokens

Test #4:

score: 0
Accepted
time: 6ms
memory: 18684kb

input:

2 2 1000
vv
>v

v>
vv

1 1 1
1 2 2
1 1 2
2 1 2
1 2 1
1 1 2
2 1 2
2 2 1
1 1 2
2 1 2
1 1 1
1 1 2
2 1 2
1 2 1
1 1 2
2 1 2
2 2 1
1 1 2
2 1 2
2 1 1
1 1 2
2 1 2
1 2 1
1 1 2
2 1 2
2 2 1
1 1 2
2 1 2
1 2 2
1 1 2
2 1 2
1 2 1
1 1 2
2 1 2
2 2 1
1 1 2
2 1 2
1 1 1
1 1 2
2 1 2
1 2 1
1 1 2
2 1 2
2 2 1
1 1 2
2 1 2
2...

output:

2
-1
-1
-1
-1
-1
-1
1
-1
1
-1
-1
-1
2
-1
-1
-1
2
-1
-1
-1
1
-1
1
-1
-1
-1
-1
-1
-1
1
-1
1
-1
-1
-1
-1
-1
2
-1
-1
-1
0
-1
-1
-1
2
-1
-1
-1
-1
-1
1
-1
1
-1
-1
-1
-1
-1
-1
1
-1
1
-1
-1
-1
2
-1
-1
-1
2
-1
-1
-1
1
-1
1
-1
-1
-1
-1
-1
-1
-1
1
-1
-1
-1
2
-1
1
-1
-1
-1
-1
-1
-1
-1
1
-1
2
-1
-1
-1
1
-1
-1
-1...

result:

ok 1001 tokens

Test #5:

score: 0
Accepted
time: 2ms
memory: 18676kb

input:

2 3 1000
vv>
v>v

>>v
v>v

1 2 1
1 2 2
1 2 3
1 1 2
2 1 2
1 2 2
1 1 2
2 1 2
2 2 2
1 1 2
2 1 2
1 1 1
1 1 2
2 1 2
1 2 2
1 1 2
2 1 2
2 2 2
1 1 2
2 1 2
2 1 1
1 1 2
2 1 2
1 2 2
1 1 2
2 1 2
2 2 2
1 1 2
2 1 2
1 2 1
1 1 2
2 1 2
1 2 2
1 1 2
2 1 2
2 2 2
1 1 2
2 1 2
1 1 1
1 1 2
2 1 2
1 2 2
1 1 2
2 1 2
2 2 2
1 1...

output:

7
-1
-1
-1
5
-1
-1
-1
-1
-1
3
-1
2
-1
-1
2
-1
-1
6
-1
-1
-1
-1
-1
-1
3
-1
-1
-1
-1
-1
-1
3
-1
-1
7
-1
-1
5
-1
-1
-1
-1
4
-1
-1
-1
-1
3
-1
-1
1
-1
-1
5
-1
-1
-1
-1
-1
-1
5
-1
-1
-1
-1
-1
-1
2
-1
-1
6
-1
-1
6
-1
5
-1
-1
-1
-1
-1
3
-1
-1
5
-1
-1
-1
-1
-1
3
-1
2
-1
-1
2
-1
-1
6
-1
-1
-1
-1
-1
-1
3
-1
-1...

result:

ok 1001 tokens

Test #6:

score: 0
Accepted
time: 653ms
memory: 18484kb

input:

1 10 100000
v>>>>>>v>>

>v>vvvvvvv

1 1 3
1 1 8
1 1 1
2 1 1
1 1 7
1 1 1
2 1 1
2 1 7
1 1 1
2 1 1
1 1 2
1 1 1
2 1 1
1 1 7
1 1 1
2 1 1
2 1 7
1 1 1
2 1 1
2 1 2
1 1 1
2 1 1
1 1 7
1 1 1
2 1 1
2 1 7
1 1 1
2 1 1
1 1 5
1 1 1
2 1 1
1 1 7
1 1 1
2 1 1
2 1 7
1 1 1
2 1 1
1 1 2
1 1 1
2 1 1
1 1 7
1 1 1
2 1 1
2 1 7
...

output:

135
139
11
10
9
73
74
75
139
138
137
139
140
141
77
76
75
11
12
13
15
14
13
77
78
79
143
142
141
157
158
159
95
94
93
29
30
31
29
28
27
91
92
93
157
156
155
153
154
155
91
90
89
25
26
27
43
42
41
105
106
107
171
170
169
171
172
173
109
108
107
43
44
45
47
46
45
109
110
111
175
174
173
429
430
431
36...

result:

ok 100001 tokens

Test #7:

score: 0
Accepted
time: 602ms
memory: 18540kb

input:

9 1 100000
>
>
v
>
v
>
v
>
v

>
v
>
v
v
>
>
>
v

1 1 1
1 5 1
1 6 1
1 8 1
1 9 1
1 2 1
2 2 1
1 3 1
1 2 1
2 2 1
2 3 1
1 2 1
2 2 1
1 4 1
1 2 1
2 2 1
1 3 1
1 2 1
2 2 1
2 3 1
1 2 1
2 2 1
2 4 1
1 2 1
2 2 1
1 3 1
1 2 1
2 2 1
2 3 1
1 2 1
2 2 1
1 9 1
1 2 1
2 2 1
1 3 1
1 2 1
2 2 1
2 3 1
1 2 1
2 2 1
1 4 1
1 2 1...

output:

58
59
43
75
203
53
51
49
53
55
57
61
59
57
49
51
53
49
47
45
41
43
45
37
35
33
37
39
41
45
43
41
215
213
211
215
217
219
223
221
219
211
213
215
211
209
207
203
205
207
199
197
195
199
201
203
207
205
203
53
51
49
53
55
57
61
59
57
49
51
53
49
47
45
41
43
45
37
35
33
37
39
41
45
43
41
25
27
29
25
23...

result:

ok 100001 tokens

Test #8:

score: 0
Accepted
time: 703ms
memory: 18620kb

input:

3 3 100000
>>>
vvv
>>v

>>>
vv>
>vv

1 1 1
1 1 2
1 1 3
1 2 1
1 2 2
1 3 1
1 3 3
1 3 1
2 3 1
1 2 2
1 3 1
2 3 1
2 2 2
1 3 1
2 3 1
1 2 1
1 3 1
2 3 1
1 2 2
1 3 1
2 3 1
2 2 2
1 3 1
2 3 1
2 2 1
1 3 1
2 3 1
1 2 2
1 3 1
2 3 1
2 2 2
1 3 1
2 3 1
1 1 2
1 3 1
2 3 1
1 2 2
1 3 1
2 3 1
2 2 2
1 3 1
2 3 1
1 2 1
1 3 1...

output:

8
-1
-1
7
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
5
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
5
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 100001 tokens

Test #9:

score: 0
Accepted
time: 502ms
memory: 18548kb

input:

4 4 100000
v>v>
>>v>
vv>>
>>.>

vv>v
vv>>
v>>>
vv.>

1 1 1
1 2 4
1 3 1
1 3 3
1 3 4
1 4 4
1 4 2
2 4 2
1 2 1
1 4 2
2 4 2
2 2 1
1 4 2
2 4 2
1 2 2
1 4 2
2 4 2
1 2 1
1 4 2
2 4 2
2 2 1
1 4 2
2 4 2
2 2 2
1 4 2
2 4 2
1 2 1
1 4 2
2 4 2
2 2 1
1 4 2
2 4 2
1 1 2
1 4 2
2 4 2
1 2 1
1 4 2
2 4 2
2 2 1
1 4 2
2 4 2
1...

output:

26
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100001 tokens

Test #10:

score: 0
Accepted
time: 745ms
memory: 18960kb

input:

1 100 100000
v>vv>>vvv>>>>v>>>vvv>>>>v>>>vv>>vv>v>v>vv>vv>vvv>>>>vv>v>vvv>v>vv>>>vv>>>v>>v>>v>>vv>v>>>vvvv>>v>vv>

vvvv>>v>v>v>>v>vv>v>vv>v>>>>>v>v>>v>>>>>>>>v>vv>v>vv>>>vvv>vv>>>>v>vvvvvvv>v>v>v>>>>>>vv>v>>>>v>>>>v

1 1 8
2 1 62
2 1 53
2 1 91
2 1 25
2 1 65
2 1 71
1 1 54
2 1 59
2 1 98
1 1 56
1 1 89
...

output:

130162746902623059640821711746
130162746902623059640821711874
130162746904928902650035405826
130162746904933406249662776322
131400686944218786524561900546
131400686944218786524578677762
131400686962665530598288229378
131400685782073909880876925954
131400685782082917080131666946
131400685782371147456...

result:

ok 100001 tokens

Test #11:

score: 0
Accepted
time: 800ms
memory: 18800kb

input:

100 1 100000
>
v
>
v
v
>
v
>
>
v
v
>
v
v
>
>
>
v
>
>
v
>
>
>
v
v
v
>
>
>
v
v
>
v
>
>
>
v
v
v
v
>
>
>
v
v
>
>
>
v
v
v
v
v
v
v
>
>
>
v
>
>
>
>
>
v
>
>
v
>
v
>
>
>
v
>
v
v
v
v
v
v
>
>
>
>
>
v
>
>
v
v
v
v
>
v
>
v
>
v

v
>
v
v
v
>
>
>
>
>
v
v
>
v
v
>
>
v
v
>
>
v
v
v
>
>
v
>
v
>
v
v
v
>
>
v
v
>
>
v
v
>
v
...

output:

373624807217797461802635479613
373624806922649556623282653757
374243776942292246760732215869
576494173228879804361795188163
576532858855107472495385785795
576532858855107507679757874627
576532858855107507679757874755
576532858855107507679757940291
576532858855107507679755843139
576532858855107507679...

result:

ok 100001 tokens

Test #12:

score: 0
Accepted
time: 2165ms
memory: 64484kb

input:

100 100 100000
vvvvv>vv>vv>>>v>>vv>vv>v>>v>>>v>v>v>>vvvvvv>v>>v>>>>>vv>>>v>v>>vvv>>vvvvvvvvvv>v>v>v>>v>vvv>>>vv>>vv
>>>v>vvv>>>vvvvvv>v>>>vv>>vvvv>>>>>>vv>>vv>>>>>v>>vv>>>vvv>>vvvv>>>v>>vv>v>v>>v>v>>vv>>v>>v>>>vv>v>v
vvv>>>v>v>>vv>vv>>>v>>>vv>vvvv>v>>>v>v>v>>>>vvv>>vvv>vvvvv>>>v>>>v>v>>vvvv>>vvvv>>v...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100001 tokens

Test #13:

score: 0
Accepted
time: 2019ms
memory: 57020kb

input:

100 100 100000
>>v>v>vvv>v>vv>>v>>v>>v>vvv>vv>v>>>>>>>vv>vv>>>>vvvv>>>v>>v>v>>>....................................
v>>>>v>.>vvvv>v>>>>vvvv>>vvv>>v>.vv>>>>.>>vvvvvv>v>v>v>vv>v>vv>v>...................................
>>vv>>v>vvvv>>>>>vv>>vvv>v>v.>>>vv>vvvv>>>.vvv>v.>>>vvvvv>vvvv>>v>>vvv>vvvv>v>vv>vv...

output:

253528151914256935978069277722645579058348007113389173875510
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

ok 100001 tokens

Test #14:

score: 0
Accepted
time: 2115ms
memory: 64348kb

input:

100 100 100000
vvv>>v>>vvv>v>>vv>>>vv>>>>v>>vv>>>>vvvv>v>v>>v>vvvvv>vv>vvv>>v>vv>vvv>>>>>vvvv>vvvvv>v>v>>v>v>>>>>v>
>vv>v>vvv>v>>>vv>>v>>v>v>>vvvvvvvv>>>vv>>vv>vv>v>v>>>v>v>v>vv>>>>>v>>v>v>>v>v>v>>>>>v>>vv>>>v>vv>>>v
v>v>v>v>>>v>>v>>>>>>>v>vv>vv>>>>v>>v>>vvv>v>v>>>vv>vvv>vv>vv>v>vvvv>vv>>>>vv>>>vvvv...

output:

23386290453762822566412058133305892764924256716359048750097
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100001 tokens

Test #15:

score: 0
Accepted
time: 1835ms
memory: 51816kb

input:

100 100 100000
vv>v>...............................................................................................
>vvvvv>vvv>>v>vvv>vv>>v.............................................................................
>vvv>>vv>.v>vv.vvv>v>v>v>>>...........................................................

output:

42658660090357251640628465467726161658558031734734431452118
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100001 tokens

Test #16:

score: 0
Accepted
time: 1298ms
memory: 27044kb

input:

100 100 100000
>>>v................................................................................................
v.v.................................................................................................
v.>v..................................................................................

output:

43815677202469463796265627043100870828664328138117793224362
-1
43815677202469463796265627043100870828664328138117793224361
-1
43815677202469463796265627043100870828664328138117793224360
-1
-1
-1
43815677202469463796265627043100870828664328138117793224359
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100001 tokens

Test #17:

score: 0
Accepted
time: 924ms
memory: 19652kb

input:

100 100 100000
vvvv................................................................................................
v...................................................................................................
v.....................................................................................

output:

222453068264192526417000218257812802177233353809948814995323
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

ok 100001 tokens

Test #18:

score: 0
Accepted
time: 1806ms
memory: 39664kb

input:

100 100 100000
>v>>v...............................................................................................
>vvv>>..............................................................................................
>>vv.v>>>.............................................................................

output:

201750991551104042432020447813933605717073792565088416920
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1...

result:

ok 100001 tokens

Test #19:

score: 0
Accepted
time: 1352ms
memory: 42524kb

input:

100 100 100000
v>v>>vvv............................................................................................
>v.>.>>v>vvv>>>.....................................................................................
......>vv.>v>>v.......................................................................

output:

39016689483511987693168985971494459264198641421031014240019
-1
39016689483511987693168985971494459264198641421031014240019
-1
39016689483511987693168985971494459264198641421031014240019
-1
39016689483511987693168985971494459264198641421031014240019
-1
390166894835119876931689859714944592641986414210...

result:

ok 100001 tokens

Test #20:

score: 0
Accepted
time: 1241ms
memory: 49432kb

input:

100 100 100000
>...................................................................................................
>v>>>v>.............................................................................................
v>vvvv>>..............................................................................

output:

124624611308017348521697627034445754534951315753056709418940
124624611308017348521697627034445754534951315753056709418939
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
124624611308017348521697627034445754534951315753056709418938
124624611308017348521697627034445754534951315753056709418939
-1
-1
-1
-1...

result:

ok 100001 tokens

Test #21:

score: 0
Accepted
time: 954ms
memory: 64292kb

input:

100 100 100000
vv>v>v>>v>>v>v>vvv>>>vv>vvvvvv>v>>>>v>>v............................................................
vvv>>>vv>vv>>>>>vvv>>vv>v>>>v>vv>>>>vvv>>vv>v>v>vvv>>vvv>v>v>>>v>v>v>v>>>>v>>vvv>>vvv>vv>>v>vv>vvvv>
>>>>>v>>>vvv>v>>vv>vv>>>>>vvvvv>vv>v>v>v>>>>>vvv>>vvvv.>>v>>vvv>>v>vvvvvvvvv>v>v>v>...

output:

107671931810604867317823529653294578411322501736483480318371
93195323721768917124921731889350746903952872486365624094301
107671931810604867317823529653294578411322501736483480318371
294062579254142701567666993431996072219228246709214728506973
107671931810604867317823529653294578411322501736483480318...

result:

ok 100001 tokens

Test #22:

score: 0
Accepted
time: 856ms
memory: 64504kb

input:

100 100 100000
>vvv>>vv>>>>>>vvv>v>>>>vv>vvvv>>>v>v>vv>>>vv>>v>>>>>>>>vvvvv>>vv>>v>>>v>vv>v>>v>vv>vvvvvv>>>>vvv>vvv
vvvv>vvv>v>>>>vv>vvv>>vv>>>v>>vvv>>>v>>v>>v>>>>v>>>>>vv>>vvv>vvvvv>v>>>>>vv>>>>v>>vvv>>>v>vvvv>v>vv>
v>>v>v>>>v>>>>>vvvvv>v>>vvv>>v>vv>v>vv>vv>v>>vvv>>>vvvvv>>>>>>vvv>v>>>vv>vvvv>>>vv>...

output:

17082601553275761539905298915831996601457557630861824921682
-1
17082601553275761539905298915831996601457557630861824921682
-1
17082601553275761539905298915831996601457557630861824921682
-1
17082601553275761539905298915831996601457557630861824921682
-1
170826015532757615399052989158319966014575576308...

result:

ok 100001 tokens

Test #23:

score: 0
Accepted
time: 1854ms
memory: 52524kb

input:

100 100 100000
v>vv>>>vvvv>>>v>>vv>v>vvvvvvvv>vvvv>v>vv>v>>vv>v>v>>>vvv>vv>>>vvv>v>vvv>v>v>vv>>>vv>vvvvv>v>vv>vv>>v
>.>.>.>.>.v.v.>.v.v.>.v.v.v.>.v.>.v.>.v.v.>.v.>.>.v.>.>.>.>.>.>.>.>.>.v.v.v.>.v.v.>.v.v.v.v.>.v.v.v.
vvvv>vv>v>>vv>v>vvv>>>vvvv>>>v>v>v>vvvv>v>>v>vvv>>>v>>v>>>>v>>v>>>v>v>v>vvv>>>v>>v>...

output:

18784946845871147976358177942986863608005443350565495986568
-1
18784946845871147976358177942986863608005443350565495986567
-1
18784946845871147976358177942986863608005443350565495986567
-1
18784946845871147976358177942986863608005443350565495986567
-1
187849468458711479763581779429868636080054433505...

result:

ok 100001 tokens

Test #24:

score: 0
Accepted
time: 1576ms
memory: 45656kb

input:

100 100 100000
>>>>>>>>>>>>>>>>>>>>>>>v>>>>>>>>>>>>>>>>>v>>>>>>>>v>v>>>>>>>>>>>v>>>>>>>>>>>>>>>>>>>>>>>>v>>>>>>>>>>
>>.>>.>>.>>.>>.>v.>>.>>.>>.>>.>>.>>.vv.>>.>>.>>.>>.>>.>>.>>.>>.>>.>>.>>.>>.>>.>>.>>.>>.>>.>>.>>.>>.>
>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..>..v..>..>..v..>..>..>..>..>....

output:

53381669762158452489209327555144242907672197839891108814646
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100001 tokens

Test #25:

score: 0
Accepted
time: 1103ms
memory: 45824kb

input:

100 100 100000
>>>>>>>v>>>>vv>>>>>v>>>v>>>>v>v>>v>>>>>>>>>>>>>v>>>v>v>>>>>v>>>v>>>>>>>>>>vvv>v>>>>>>v>v>>vv>>v>v>v>
>>.>v.>v.>v.>>.>>.>>.>v.>v.>>.>>.v>.v>.>>.v>.>v.v>.v>.>>.>v.>v.>v.>>.>>.>>.>>.>v.v>.>>.>v.>>.v>.v>.>
v..>..v..>..v..>..>..>..v..v..>..>..>..>..>..>..v..v..>..v..>..>..>..>..>..>..>..v....

output:

57275352746220220487283409946985056949752315135185187188423
-1
57275352746220220487283409946985056949752315135185187188423
-1
57275352746220220487283409946985056949752315135185187188423
-1
57275352746220220487283409946985056949752315135185187188423
-1
572753527462202204872834099469850569497523151351...

result:

ok 100001 tokens

Test #26:

score: 0
Accepted
time: 1183ms
memory: 45776kb

input:

100 100 100000
vv>vv>v>>>>>>>>>>>v>vv>v>>>>>v>vvv>>>>>>vv>>>>>vv>v>>v>>>>>v>>>v>>>vv>v>v>vvv>>>vv>>>>v>>v>>>v>>>vv>
>>.>>.vv.>>.>v.vv.v>.>>.v>.v>.v>.vv.>v.>>.vv.>v.vv.>>.vv.>>.vv.>>.>v.v>.>>.>v.v>.v>.>v.vv.>v.>v.v>.v
>..>..v..>..>..>..>..v..v..>..>..>..>..v..>..>..>..>..>..>..>..v..v..>..>..v..>..v....

output:

64907501743444547022137361805387261917105074916262651128947
-1
64907501743444547022137361805387261917105074916262651128947
-1
64907501743444547022137361805387261917105074916262651128947
-1
64907501743444547022137361805387261917105074916262651128947
-1
649075017434445470221373618053872619171050749162...

result:

ok 100001 tokens

Test #27:

score: 0
Accepted
time: 1329ms
memory: 45600kb

input:

100 100 100000
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv>vvvvv>vvvvvvvvvvvvvvvvv>vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.vv.>v.vv.vv.vv.vv.v
v..v..v..v..v..v..v..v..v..v..v..v..v..v..v..v..v..v..v..v..v..v..v..v..v..v..v..v....

output:

21976302509188623113582373479770928527855534478211028789917
-1
21976302509188623113582373479770928527855534478211028789917
-1
21976302509188623113582373479770928527855534478211028789917
-1
21976302509188623113582373479770928527855534478211028789917
-1
219763025091886231135823734797709285278555344782...

result:

ok 100001 tokens

Test #28:

score: 0
Accepted
time: 1132ms
memory: 20924kb

input:

100 100 100000
>>..................................................................................................
>>..................................................................................................
>>v>>.................................................................................

output:

4899093492166070486573268177568463493559612269189682940140
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 100001 tokens

Test #29:

score: 0
Accepted
time: 1125ms
memory: 25104kb

input:

100 100 100000
vv>vvvv.............................................................................................
v>vvv.v.............................................................................................
vvv>>vvvv.............................................................................

output:

5852208803576017905737030078378565171209408740723222843758
-1
5852208803576017905737030078378565171209408740723222843758
-1
5852208803576017905737030078378565171209408740723222843758
-1
5852208803576017905737030078378565171209408740723222843758
-1
5852208803576017905737030078378565171209408740723222...

result:

ok 100001 tokens

Test #30:

score: 0
Accepted
time: 1723ms
memory: 30588kb

input:

100 100 100000
>>>.................................................................................................
>>>>>v..............................................................................................
>>>>v>>>..............................................................................

output:

229725942343818046032259298037952089749446429318663445046838
-1
-1
229725942343818046032259298037952089749446429318663445046839
-1
-1
-1
-1
-1
-1
-1
-1
-1
229725942343818046032259298037952089749446429318663445046840
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100001 tokens