QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#440670#7259. RobotsI_Love_Sonechka#AC ✓260ms41724kbC++173.1kb2024-06-13 22:31:212024-06-13 22:31:23

Judging History

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

  • [2024-06-13 22:31:23]
  • 评测
  • 测评结果:AC
  • 用时:260ms
  • 内存:41724kb
  • [2024-06-13 22:31:21]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

// c++ short types
#define vt vector
//typedef long long ll;
typedef long double ld;

void whattime() { cout << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl; }
const int64_t inf = 1e18;
const int mod = 998244353;
bool debug = false;
const ld eps = 1e-9;

mt19937_64 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());

string dir = "URDL";
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

void solve() {
	int n;
	int64_t T;
	cin >> n >> T;
	vt<int> x(n), y(n);
	vt<char> c(n);
	map<pair<int, int>, int> ids;
	map<int, vt<pair<int, int>>> x_line;
	map<int, vt<pair<int, int>>> y_line;
	for(int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i] >> c[i];
		ids[make_pair(x[i], y[i])] = i;
		x_line[x[i]].push_back(make_pair(y[i], i));
		y_line[y[i]].push_back(make_pair(x[i], i));
	}
	vt<vt<int>> g(n);
	for(auto &zz: x_line) {
		auto &v = zz.second;
		sort(v.begin(), v.end());
		for(int i = 0; i + 1 < int(v.size()); ++i) {
			g[v[i].second].push_back(v[i+1].second);
			g[v[i+1].second].push_back(v[i].second);
		}
	}
	for(auto &zz: y_line) {
		auto &v = zz.second;
		sort(v.begin(), v.end());
		for(int i = 0; i + 1 < int(v.size()); ++i) {
			g[v[i].second].push_back(v[i+1].second);
			g[v[i+1].second].push_back(v[i].second);
		}
	}
	auto get_id = [&](char c) {
		for(int i = 0; i < 4; ++i) if(dir[i] == c) {
			return i;
		}
		assert(false);
		return -1;
	};
	auto is_ok = [&](int x, int y, int nx, int ny, int type) {
		int dxx = nx - x, dyy = ny - y;
		if(dxx + dyy == 0) {
			return true;
		}
//		string dir = "URDL";
		int ztype = 0;
		if(dyy > 0) {
			ztype = 0;
		} else if(dxx > 0) {
			ztype = 1;
		} else if(dyy < 0) {
			ztype = 2;
		} else if(dxx < 0) {
			ztype = 3;
		}
		return ztype == type;
	};
	vt<vt<int64_t>> dp(n, vt<int64_t>(4, inf));
	dp[0][get_id(c[0])] = 0;
	set<pair<int64_t, pair<int, int>>> st;
	st.insert(make_pair(0ll, make_pair(0, get_id(c[0]))));
	while(not st.empty()) {
		auto u = st.begin()->second;
		int e = u.first, type = u.second;
		st.erase(st.begin());
		for(auto to: g[e]) if(is_ok(x[e], y[e], x[to], y[to], type)) {
			int delta = abs(x[e]-x[to]) + abs(y[e]-y[to]);
			if(delta + dp[e][type] < dp[to][type]) {
				st.erase(make_pair(dp[to][type], make_pair(to, type)));
				st.insert(make_pair(dp[to][type] = delta + dp[e][type], make_pair(to, type)));
			}
		}
		int cur_id = get_id(c[e]);
		if(dp[e][cur_id] > dp[e][type]) {
			st.erase(make_pair(dp[e][cur_id], make_pair(e, cur_id)));
			st.insert(make_pair(dp[e][cur_id] = dp[e][type], make_pair(e, cur_id)));
		}
	}
	for(int i = 0; i < n; ++i) {
		int64_t time = *min_element(dp[i].begin(), dp[i].end());
		int64_t resx = x[i], resy = y[i];
		int type = get_id(c[i]);
		int64_t dtime = max(int64_t(0), T - time);
		resx += dtime * dx[type];
		resy += dtime * dy[type];
		cout << resx << ' ' << resy << '\n';
	}
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int tt = 1;
	if(debug) {
		tt = 1e5;
	} else {
//		cin >> tt;
	}
	for(int t = 0; t < tt; ++t) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3800kb

input:

5 10
1 0 U
3 1 U
1 2 R
1 1 L
0 1 R

output:

1 10
3 6
9 2
-8 1
8 1

result:

ok 10 numbers

Test #2:

score: 0
Accepted
time: 190ms
memory: 34512kb

input:

100000 1000000000000000000
158260522 833086986 U
158260522 426364560 L
158260522 759037020 R
158260522 427764980 L
158260522 603003082 L
158260522 781408312 L
158260522 596708907 U
158260522 589131680 D
158260522 30921931 L
158260522 867704537 L
158260522 594273744 R
158260522 45480206 D
158260522 5...

output:

158260522 1000000000833086986
-999999999434892416 426364560
1000000000084085920 759037020
-999999999436292836 427764980
-999999999611530938 603003082
-999999999789936168 781408312
158260522 1000000000360206192
158260522 -999999999166788378
-999999999039449787 30921931
-999999999807121927 867704537
9...

result:

ok 200000 numbers

Test #3:

score: 0
Accepted
time: 206ms
memory: 29712kb

input:

100000 1000000000000000000
233552954 47283907 D
795628008 257250937 R
795628008 550072283 U
795628008 144321804 R
795628008 108332818 L
233552954 884387100 D
795628008 869181985 U
233552954 429351010 R
795628008 629618118 R
233552954 641045921 D
233552954 177490124 L
795628008 871648024 U
233552954 ...

output:

233552954 -999999999952716093
1000000000023080040 257250937
795628008 999999999484702969
1000000000136009173 144321804
-999999998580742143 108332818
233552954 -999999998278003823
795628008 999999999484702969
999999999850979967 429351010
999999999650712859 629618118
233552954 -999999998764686181
-999...

result:

ok 200000 numbers

Test #4:

score: 0
Accepted
time: 194ms
memory: 28404kb

input:

100000 1000000000000000000
531527275 380312548 L
368745941 258142892 D
531527275 138986229 U
531527275 319183722 R
730349222 3971805 U
531527275 928719459 R
531527275 412037393 U
730349222 365643147 L
368745941 807175032 L
531527275 407014204 L
368745941 263213856 U
730349222 596241749 L
531527275 7...

output:

-999999999468472725 380312548
368745941 -999999998733348866
531527275 999999999174102658
999999999746841197 319183722
730349222 999999999102895757
999999999259913802 928719459
531527275 999999999657105986
-999999998730246072 365643147
-999999998318403679 807175032
-999999998718564507 407014204
36874...

result:

ok 200000 numbers

Test #5:

score: 0
Accepted
time: 162ms
memory: 34480kb

input:

100000 1000000000000000000
561380534 729502086 D
203720318 729502086 U
813185473 729502086 L
808991828 729502086 L
772433385 729502086 D
790724942 729502086 U
949969922 729502086 L
816502581 729502086 U
332027262 729502086 R
338024167 729502086 U
141601576 729502086 R
136947314 729502086 D
146842265...

output:

561380534 -999999999270497914
203720318 729502086
813185473 729502086
808991828 729502086
772433385 729502086
790724942 729502086
949969922 729502086
816502581 729502086
332027262 729502086
338024167 729502086
141601576 729502086
136947314 729502086
146842265 729502086
867798414 729502086
959054254 ...

result:

ok 200000 numbers

Test #6:

score: 0
Accepted
time: 128ms
memory: 28968kb

input:

100000 1000000000000000000
40633672 256815712 U
392684870 590303299 D
203773372 590303299 L
593293112 590303299 U
652768710 590303299 R
800416657 256815712 R
240188276 256815712 U
180046511 590303299 L
108474217 256815712 D
221178931 590303299 U
660419178 256815712 R
428919344 256815712 R
748315500 ...

output:

40633672 1000000000256815712
392684870 590303299
203773372 590303299
593293112 590303299
652768710 590303299
800416657 256815712
240188276 256815712
180046511 590303299
108474217 256815712
221178931 590303299
660419178 256815712
428919344 256815712
748315500 590303299
403635567 590303299
579386082 2...

result:

ok 200000 numbers

Test #7:

score: 0
Accepted
time: 200ms
memory: 28336kb

input:

100000 1000000000000000000
317153144 37563938 D
461986566 37563938 D
594935002 37563938 U
734315399 37563938 R
528773362 37563938 U
44277573 571202477 D
134752927 37563938 D
155428797 571202477 L
103525727 571202477 U
103282889 28653721 L
85539295 37563938 R
859838426 37563938 R
770381950 571202477 ...

output:

317153144 -999999999962436062
461986566 -999999998732505128
594935002 999999998674684568
999999999232055632 37563938
528773362 999999998740846208
44277573 -999999998604405851
134752927 -999999998694881205
-999999999131330755 571202477
103525727 999999999806058959
-999999998588781999 28653721
9999999...

result:

ok 200000 numbers

Test #8:

score: 0
Accepted
time: 183ms
memory: 34440kb

input:

100000 1000000000000000000
386075092 217120430 U
386075092 461633934 L
386075092 124926580 U
386075092 755378486 L
386075092 727330147 U
386075092 735921494 D
386075092 604737700 L
386075092 497592622 U
386075092 137237895 R
386075092 420767260 L
386075092 621532328 U
386075092 862570025 L
386075092...

output:

386075092 1000000000217120430
-999999999369411404 461633934
386075092 1000000000032619042
-999999999075666852 755378486
386075092 1000000000217120430
386075092 -999999998745277442
-999999999226307638 604737700
386075092 1000000000217120430
1000000000306078869 137237895
-999999999410278078 420767260
...

result:

ok 200000 numbers

Test #9:

score: 0
Accepted
time: 207ms
memory: 26884kb

input:

100000 1000000000000000000
812304066 108536522 D
393591774 293077924 R
46211797 40626753 U
251187352 317219315 L
882175209 492633736 U
803115525 885683902 U
588229145 332510814 R
46211797 958276960 L
812304066 338704537 U
776144254 281431621 D
588229145 822863750 D
803115525 179232235 U
46211797 224...

output:

812304066 -999999999891463478
999999999789937222 293077924
46211797 999999999206624715
-999999998978612283 317219315
882175209 1000000000036976417
803115525 1000000000098947123
1000000000139779074 332510814
-999999998337554638 958276960
812304066 1000000000106847560
776144254 -999999999509112610
588...

result:

ok 200000 numbers

Test #10:

score: 0
Accepted
time: 207ms
memory: 25116kb

input:

100000 1000000000000000000
636581665 627517899 U
384326252 989020485 D
850928761 393946779 D
983081163 353187253 L
849295618 175483772 R
566174368 481362418 U
748019538 444912405 D
613288153 508836830 L
868825330 176465822 U
616229375 245179297 D
337060486 876247455 L
232314466 542504776 U
985092263...

output:

636581665 1000000000627517899
384326252 -999999998397221516
850928761 -999999999149349241
-999999998387302929 353187253
1000000000175761774 175483772
566174368 1000000000262953114
748019538 -999999999252258464
-999999999238494030 508836830
868825330 999999999484384316
616229375 -999999999345886575
-...

result:

ok 200000 numbers

Test #11:

score: 0
Accepted
time: 191ms
memory: 25092kb

input:

100000 1000000000000000000
95402381 180577248 D
820355630 869868252 L
510574002 947140642 U
107928860 216094009 D
449664703 741244839 R
704619572 747440140 L
465181887 458886093 L
444544986 920794828 D
137270613 244136065 U
953971166 200566671 U
404778025 989576813 U
363490391 623360071 U
539456771 ...

output:

95402381 -999999999819422752
-999999997751978659 869868252
510574002 999999999751984169
107928860 -999999999722441293
999999999521313332 741244839
-999999998105878887 747440140
-999999998873308304 458886093
444544986 -999999997976423529
137270613 1000000000125287558
953971166 999999999308587005
4047...

result:

ok 200000 numbers

Test #12:

score: 0
Accepted
time: 223ms
memory: 26872kb

input:

100000 1000000000000000000
545737590 287413230 D
32300820 112475277 U
95613327 287413230 U
631751785 410333678 L
654111144 662448296 R
107888509 662448296 D
792438755 287413230 L
2038931 224924304 L
487248660 101766181 D
175448445 369626396 D
666765979 369626396 D
298388196 297354503 L
626256925 848...

output:

545737590 -999999999712586770
32300820 999999999423128362
95613327 999999999711338923
-999999999034335720 410333678
1000000000045724672 662448296
107888509 -999999998398717513
-999999998835882228 287413230
-999999999390801292 224924304
487248660 -999999999653158988
175448445 -999999999051921249
6667...

result:

ok 200000 numbers

Test #13:

score: 0
Accepted
time: 164ms
memory: 34620kb

input:

100000 1000000000000000000
726706648 742813187 U
170991532 742813187 U
245380683 742813187 R
239885395 742813187 L
101591873 742813187 L
537460913 742813187 L
315663936 742813187 L
997183664 742813187 L
902511844 742813187 U
845319625 742813187 R
953878031 742813187 R
32010543 742813187 R
145216145 ...

output:

726706648 1000000000742813187
170991532 742813187
245380683 742813187
239885395 742813187
101591873 742813187
537460913 742813187
315663936 742813187
997183664 742813187
902511844 742813187
845319625 742813187
953878031 742813187
32010543 742813187
145216145 742813187
876614770 742813187
364240338 7...

result:

ok 200000 numbers

Test #14:

score: 0
Accepted
time: 172ms
memory: 23084kb

input:

89153 1000000000
452747846 962556007 L
666044562 535170540 D
257716848 892169727 U
672216693 273108699 R
608110094 539410304 D
156500484 548042136 L
71885289 190801526 L
916597980 315459511 U
982334292 377295435 R
590975740 232176839 D
237457646 110507996 R
579192570 496123618 D
877322966 736953362 ...

output:

-547252154 962556007
666044562 176384675
257716848 1626752449
762768586 273108699
608110094 118450207
-132738283 548042136
71885289 190801526
916597980 315459511
982334292 377295435
590975740 101315853
237457646 110507996
579192570 89532683
528032683 736953362
139910685 242248940
738292478 597043875...

result:

ok 178306 numbers

Test #15:

score: 0
Accepted
time: 181ms
memory: 23608kb

input:

91906 10000000000
958668995 246058339 R
503666498 889608806 U
366854683 570796148 R
799588075 970911538 L
251188854 382210484 U
247006479 570796148 L
527654256 19911869 R
293192373 836376015 R
652018277 646710523 D
803588261 991615550 L
488295044 53966525 U
745200166 831380531 D
735696627 195019158 ...

output:

10958668995 246058339
503666498 9776131210
9435377930 570796148
-8301553174 970911538
251188854 9523653566
-8701668564 570796148
9855568415 19911869
9022473443 836376015
652018277 -8631061943
-8280849162 991615550
488295044 9376576128
745200166 -8354903816
10446760446 195019158
10609309364 195019158...

result:

ok 183812 numbers

Test #16:

score: 0
Accepted
time: 1ms
memory: 3952kb

input:

242 100000000000
203049518 714923922 L
441395303 860719447 R
71823579 316450815 U
743887311 533611458 R
543109434 456937805 U
389914499 40985317 L
78518189 75992808 U
16129239 74144852 L
509796392 205097343 U
67361063 826369379 L
261408260 121976261 R
428890752 526063699 U
443568088 337498527 D
9439...

output:

-99796950482 714923922
441395303 860719447
71823579 316450815
743887311 533611458
543109434 456937805
389914499 40985317
78518189 75992808
16129239 74144852
509796392 205097343
67361063 826369379
261408260 121976261
428890752 526063699
443568088 337498527
943976135 178509062
978600468 367894165
9630...

result:

ok 484 numbers

Test #17:

score: 0
Accepted
time: 35ms
memory: 8716kb

input:

24226 1000000000000
285356318 942519123 U
690346553 272667868 D
80707751 128641666 D
578149194 953490880 R
591537576 763864532 U
317662875 904722233 D
365097408 928540616 U
100191181 332175577 U
10949625 37719540 D
856015187 332240857 R
239376997 11438142 R
636643652 253919227 R
201902117 542098092 ...

output:

285356318 1000942519123
690346553 -998559928912
80707751 -998787983056
1000116303085 953490880
591537576 1000186466953
317662875 -998893399706
365097408 1000742259289
100191181 999471817640
10949625 -998718224930
999582516322 332240857
999176789801 11438142
999504194692 253919227
201902117 999993373...

result:

ok 48452 numbers

Test #18:

score: 0
Accepted
time: 131ms
memory: 18516kb

input:

67458 10000000000000
818609843 930613401 L
70389372 756883251 U
432539187 70051676 D
974910212 631543164 U
484550186 151556251 R
448654720 705355498 L
760778921 364423955 R
956741231 887095636 R
236544270 496732407 L
314387791 474881195 R
448654720 676033192 D
546664720 256976599 D
644009698 7350997...

output:

-9999181390157 930613401
70389372 9999834932630
432539187 -9998683315943
974910212 10000133392346
9999371433379 151556251
-9998956132254 705355498
10000136758553 364423955
10000732311866 887095636
-9998747509163 496732407
9999354433533 474881195
448654720 -9998699431476
546664720 -9998797441476
1000...

result:

ok 134916 numbers

Test #19:

score: 0
Accepted
time: 201ms
memory: 25016kb

input:

100000 1000000000000000000
592825996 837436381 U
580124599 603753069 R
761464601 921205988 R
238952989 715879557 U
541559959 639504333 D
731766684 887390082 R
42795453 959282614 L
81670266 989191546 D
500238990 984418695 L
445657355 499929631 U
748749171 213979296 R
373040547 164112428 L
839751287 7...

output:

592825996 1000000000837436381
1000000000306735572 603753069
1000000000509056389 921205988
238952989 1000000000213445408
541559959 -999999999084293264
1000000000542872295 887390082
-999999999285327771 959282614
81670266 -999999998347897559
-999999999260191690 984418695
445657355 999999999988249922
99...

result:

ok 200000 numbers

Test #20:

score: 0
Accepted
time: 224ms
memory: 26140kb

input:

100000 1000000000000000000
666277986 159178888 R
591518992 201116843 D
5384772 513343753 L
803303889 722536184 L
104886651 943161505 L
129106136 984892627 R
94716700 420439050 R
762551540 318043220 D
824140771 647854341 U
972697192 762692570 R
489606513 568767496 R
224322011 310480922 L
397238075 41...

output:

1000000000666277986 159178888
591518992 -999999999579455514
-999999998978305285 513343753
-999999998496312912 722536184
-999999998548487533 943161505
999999998764968683 984892627
999999999260643388 420439050
762551540 -999999999426223786
824140771 1000000000001316103
1000000000062764304 762692570
99...

result:

ok 200000 numbers

Test #21:

score: 0
Accepted
time: 260ms
memory: 27140kb

input:

100000 1000000000000000000
829714962 808467768 R
964319842 920533064 D
180614597 177949083 U
38188492 507979841 R
463449590 82199217 D
534347131 786538449 D
324591598 668719224 D
596142697 537650126 U
65552376 308568626 U
40998477 771874906 D
752153899 473933471 R
662177086 465489672 U
235573357 190...

output:

1000000000829714962 808467768
964319842 -999999998447796436
180614597 999999998830414811
999999998866360637 507979841
463449590 -999999998642658912
534347131 -999999998334091163
324591598 -999999998475370706
596142697 999999999810194927
65552376 999999998903636938
40998477 -999999998168453177
100000...

result:

ok 200000 numbers

Test #22:

score: 0
Accepted
time: 245ms
memory: 28500kb

input:

100000 1000000000000000000
952227250 823291392 D
709686642 725165530 D
691423285 213889225 R
200279445 575351813 D
156994593 262801002 L
158221808 966218297 U
95896317 390655321 L
913194478 117624061 R
201399824 853464584 L
349441111 487546370 D
378232583 937955079 U
458428974 354909275 R
290698550 ...

output:

952227250 -999999999176708608
709686642 -999999996980760384
999999996733114765 213889225
200279445 -999999995569031779
-999999995586295722 262801002
158221808 999999997039481410
-999999996601270599 390655321
999999997181202903 117624061
-999999995734518166 853464584
349441111 -999999996114708307
378...

result:

ok 200000 numbers

Test #23:

score: 0
Accepted
time: 187ms
memory: 31796kb

input:

100000 1000000000000000000
253685402 394065730 L
715663507 323731110 L
635131545 724754972 D
647819839 760698125 L
331875175 123596160 D
178535314 895557870 R
119174218 57328107 R
527931138 801549489 U
300878016 718390088 R
933426015 987501358 D
749368094 863704872 R
604656838 630208563 L
142589297 ...

output:

-999999999746314598 394065730
715663507 323731110
635131545 724754972
647819839 760698125
331875175 123596160
178535314 895557870
119174218 57328107
527931138 801549489
300878016 718390088
933426015 987501358
749368094 863704872
604656838 630208563
142589297 669279926
572118375 694365146
348786288 1...

result:

ok 200000 numbers

Test #24:

score: 0
Accepted
time: 144ms
memory: 34452kb

input:

100000 1000000000000000000
775679740 954819331 U
775679740 961500530 U
775679740 901490976 U
775679740 260604449 U
775679740 93919169 U
775679740 714296748 U
775679740 822310660 U
775679740 430326449 U
775679740 471049612 U
775679740 62024374 U
775679740 183617169 U
775679740 745138150 U
775679740 6...

output:

775679740 1000000000954819331
775679740 1000000000954819331
775679740 901490976
775679740 260604449
775679740 93919169
775679740 714296748
775679740 822310660
775679740 430326449
775679740 471049612
775679740 62024374
775679740 183617169
775679740 745138150
775679740 6227181
775679740 403042388
7756...

result:

ok 200000 numbers

Test #25:

score: 0
Accepted
time: 192ms
memory: 34616kb

input:

100000 1000000000000000000
782906609 133235274 U
782906609 836712760 D
782906609 242210260 U
782906609 162010416 D
782906609 608862474 D
782906609 260635087 U
782906609 633484200 U
782906609 954612787 D
782906609 463715688 U
782906609 904305316 D
782906609 886592899 D
782906609 901362376 D
782906609...

output:

782906609 1000000000133235274
782906609 -999999998459809754
782906609 1000000000133235274
782906609 -999999999809214442
782906609 -999999998915510326
782906609 1000000000133235274
782906609 1000000000133235274
782906609 -999999998224009700
782906609 1000000000133235274
782906609 -999999998324624642
...

result:

ok 200000 numbers

Test #26:

score: 0
Accepted
time: 163ms
memory: 29176kb

input:

100000 1000000000000000000
904492027 527595435 U
904492027 507833832 U
320683452 830672563 U
320683452 723405646 U
320683452 152800852 U
320683452 365287346 U
904492027 102302094 U
904492027 768282383 U
320683452 164505676 U
320683452 142847181 U
904492027 558212267 U
320683452 773970745 U
320683452...

output:

904492027 1000000000527595435
904492027 507833832
320683452 830672563
320683452 723405646
320683452 152800852
320683452 365287346
904492027 102302094
904492027 1000000000527595435
320683452 164505676
320683452 142847181
904492027 1000000000527595435
320683452 773970745
320683452 858571160
904492027 ...

result:

ok 200000 numbers

Test #27:

score: 0
Accepted
time: 145ms
memory: 29184kb

input:

100000 1000000000000000000
940767425 124739249 D
744756599 542257788 D
744756599 141763433 U
940767425 228308715 D
744756599 585682143 D
744756599 207781181 D
940767425 717421747 U
940767425 659685715 D
940767425 878607688 D
744756599 226499117 U
940767425 212273515 U
744756599 101032586 U
940767425...

output:

940767425 -999999999875260751
744756599 542257788
744756599 141763433
940767425 -999999999668108125
744756599 585682143
744756599 207781181
940767425 1000000000124725555
940767425 -999999998805354125
940767425 -999999998367510179
744756599 226499117
940767425 1000000000124725555
744756599 101032586
...

result:

ok 200000 numbers

Test #28:

score: 0
Accepted
time: 139ms
memory: 28900kb

input:

100000 1000000000000000000
397746824 159049030 U
1703392 159049030 U
419939112 159049030 U
835014838 159049030 U
148936277 541749540 U
540356926 541749540 U
938548843 159049030 U
314304736 541749540 U
288847838 159049030 U
557518189 541749540 U
665107448 541749540 U
817979433 159049030 U
370094664 1...

output:

397746824 1000000000159049030
1703392 159049030
419939112 159049030
835014838 159049030
148936277 541749540
540356926 541749540
938548843 159049030
314304736 541749540
288847838 159049030
557518189 541749540
665107448 541749540
817979433 159049030
370094664 159049030
830449643 159049030
53001089 159...

result:

ok 200000 numbers

Test #29:

score: 0
Accepted
time: 126ms
memory: 29200kb

input:

100000 1000000000000000000
723992675 321471314 U
156254457 528919984 D
733307343 321471314 D
739607186 321471314 U
111573745 321471314 U
982157705 321471314 D
391119043 528919984 D
285490374 528919984 D
4668338 528919984 U
181077136 321471314 D
684818728 321471314 U
220466330 321471314 D
87802746 32...

output:

723992675 1000000000321471314
156254457 528919984
733307343 321471314
739607186 321471314
111573745 321471314
982157705 321471314
391119043 528919984
285490374 528919984
4668338 528919984
181077136 321471314
684818728 321471314
220466330 321471314
87802746 321471314
242198231 528919984
113527844 321...

result:

ok 200000 numbers

Test #30:

score: 0
Accepted
time: 128ms
memory: 34600kb

input:

100000 1000000000000000000
675407479 250089291 U
451161204 250089291 U
910761092 250089291 U
947320836 250089291 U
833457294 250089291 U
81278027 250089291 U
22555177 250089291 U
746328324 250089291 U
313377959 250089291 U
331235659 250089291 U
855637035 250089291 U
814293766 250089291 U
873814413 2...

output:

675407479 1000000000250089291
451161204 250089291
910761092 250089291
947320836 250089291
833457294 250089291
81278027 250089291
22555177 250089291
746328324 250089291
313377959 250089291
331235659 250089291
855637035 250089291
814293766 250089291
873814413 250089291
155796125 250089291
316452466 25...

result:

ok 200000 numbers

Test #31:

score: 0
Accepted
time: 150ms
memory: 34480kb

input:

100000 1000000000000000000
196189124 228526447 U
477932095 228526447 D
687059944 228526447 D
326471760 228526447 U
341135829 228526447 U
176113468 228526447 D
920109629 228526447 U
620056117 228526447 U
760286493 228526447 D
366391761 228526447 D
221820453 228526447 D
96710438 228526447 D
586963241 ...

output:

196189124 1000000000228526447
477932095 228526447
687059944 228526447
326471760 228526447
341135829 228526447
176113468 228526447
920109629 228526447
620056117 228526447
760286493 228526447
366391761 228526447
221820453 228526447
96710438 228526447
586963241 228526447
144230445 228526447
75325393 22...

result:

ok 200000 numbers

Test #32:

score: 0
Accepted
time: 67ms
memory: 34504kb

input:

100000 1000000000
0 100000 D
0 99999 D
0 99998 D
0 99997 D
0 99996 D
0 99995 D
0 99994 D
0 99993 D
0 99992 D
0 99991 D
0 99990 D
0 99989 D
0 99988 D
0 99987 D
0 99986 D
0 99985 D
0 99984 D
0 99983 D
0 99982 D
0 99981 D
0 99980 D
0 99979 D
0 99978 D
0 99977 D
0 99976 D
0 99975 D
0 99974 D
0 99973 D
0...

output:

0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0 -999900000
0...

result:

ok 200000 numbers

Test #33:

score: 0
Accepted
time: 184ms
memory: 34420kb

input:

100000 1000000000000000000
473921396 890834979 U
473921396 711582662 L
473921396 883086059 D
473921396 871996608 D
473921396 241283927 L
473921396 393400367 U
473921396 642627261 R
473921396 643919931 D
473921396 818596795 U
473921396 511624257 D
473921396 214586767 U
473921396 86562934 L
473921396 ...

output:

473921396 1000000000890834979
-999999999346703263 711582662
473921396 -999999999109041997
473921396 -999999999109041997
-999999998876404528 241283927
473921396 999999999895842731
1000000000225590654 642627261
473921396 -999999999109041997
473921396 1000000000746235587
473921396 -999999999109041997
4...

result:

ok 200000 numbers

Test #34:

score: 0
Accepted
time: 193ms
memory: 34616kb

input:

100000 1000000000000000000
894449066 575115655 U
894449066 840501706 L
894449066 986139460 L
894449066 892106502 D
894449066 804680105 U
894449066 431206968 D
894449066 997399168 R
894449066 715555274 U
894449066 929661303 L
894449066 567463953 D
894449066 539372720 D
894449066 349388115 U
894449066...

output:

894449066 1000000000575115655
-999999998840164883 840501706
-999999998694527129 986139460
894449066 -999999998790902651
894449066 1000000000575115655
894449066 -999999999424710977
1000000000472165553 997399168
894449066 1000000000575115655
-999999998751005286 929661303
894449066 -999999999424710977
...

result:

ok 200000 numbers

Test #35:

score: 0
Accepted
time: 255ms
memory: 41724kb

input:

100000 1000000000000000000
259474019 781547542 L
211709778 840501706 D
225226213 986139460 R
141335940 892106502 U
242296739 804680105 R
250903632 431206968 R
112753503 997399168 R
67484165 715555274 D
199596425 929661303 D
55947339 567463953 R
219918200 539372720 R
156067648 349388115 U
193774631 2...

output:

-999999999740525981 781547542
211709778 840501706
225226213 986139460
141335940 892106502
242296739 804680105
250903632 431206968
112753503 997399168
67484165 715555274
199596425 929661303
55947339 567463953
219918200 539372720
156067648 349388115
193774631 296329965
224121005 767644418
45703807 312...

result:

ok 200000 numbers

Test #36:

score: 0
Accepted
time: 167ms
memory: 34812kb

input:

100000 1000000000000000000
918270168 57575548 D
918270168 538029753 R
918270168 656461613 U
918270168 846616703 U
918270168 398233347 R
918270168 238852782 L
918270168 275474249 R
918270168 145362945 D
918270168 538379377 U
918270168 293175139 D
918270168 228202124 D
918270168 310271226 U
918270168 ...

output:

918270168 -999999999942424452
1000000000437623027 538029753
918270168 1000000000057382612
918270168 1000000000057382612
1000000000577419433 398233347
-999999998900259662 238852782
1000000000700178531 275474249
918270168 -999999999766656722
918270168 1000000000057382612
918270168 -999999999471032334
...

result:

ok 200000 numbers

Test #37:

score: 0
Accepted
time: 189ms
memory: 34556kb

input:

100000 1000000000000000000
382945727 643341572 U
382945727 945023696 R
382945727 920093999 D
382945727 991771365 R
382945727 730754030 U
382945727 631614680 D
382945727 566699483 L
382945727 291299803 R
382945727 995032423 L
382945727 725295918 R
382945727 486903260 D
382945727 405970645 L
382945727...

output:

382945727 1000000000643341572
1000000000081263603 945023696
382945727 -999999998803153574
1000000000034515934 991771365
382945727 1000000000643341572
382945727 -999999999356612764
-999999999540366520 566699483
1000000000030858294 291299803
-999999999265363422 995032423
1000000000300991381 725295918
...

result:

ok 200000 numbers