CSES - Datatähti 2021 loppu - Results
Submission details
Task:Murtoviiva
Sender:hltk
Submission time:2021-01-23 19:59:51 +0200
Language:C++17
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
#40
#50
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 4, 5details
#20.01 s1, 2, 4, 5details
#30.01 s1, 2, 4, 5details
#40.01 s1, 2, 4, 5details
#50.01 s1, 2, 4, 5details
#60.01 s2, 4, 5details
#7ACCEPTED0.01 s2, 4, 5details
#80.70 s2, 4, 5details
#90.95 s2, 4, 5details
#100.01 s2, 4, 5details
#110.95 s4, 5details
#120.97 s5details
#130.95 s3, 4, 5details
#14ACCEPTED0.95 s3, 4, 5details
#15ACCEPTED0.01 s1, 2, 4, 5details
#160.03 s4, 5details
#170.95 s4, 5details
#18--5details
#19ACCEPTED0.95 s1, 2, 4, 5details
#200.01 s2, 4, 5details
#210.95 s2, 4, 5details
#220.01 s2, 4, 5details
#230.95 s4, 5details
#240.95 s4, 5details
#25ACCEPTED0.95 s4, 5details
#26ACCEPTED0.97 s5details
#270.98 s5details
#280.97 s5details
#290.97 s5details
#300.01 s1, 2, 4, 5details

Code

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;

	vector<int> p(n);
	for (auto& x : p) cin >> x;

	string s;
	cin >> s;

	vector<int> cur(n - 1, 1);

	vector<int> x{0};
	for (int i = 0; i < 2 * n - 1; ++i) {
		if (i % 2 == 0) x.push_back(x.back() + (i / 2 % 2 ? -1 : 1) * p[i / 2]);
		else x.push_back(x.back());
	}

	auto between = [](auto v, auto r) { return r.first <= v && v <= r.second; };

	auto test = [&]() -> bool {
		static vector<int> y;
		y = {0};
		for (int i = 0; i < n * 2 - 1; ++i) {
			if (i % 2 == 0) {
				y.push_back(y.back());
			} else {
				y.push_back(y.back() + (s[i / 2] == 'D' ? 1 : -1) * cur[i / 2]);
			}
		}

		for (int i = 0; i + 1 < n * 2; i += 2) {
			for (int j = i + 3; j + 1 < n * 2; j += 2) {
				assert(y[i] == y[i + 1]);
				assert(x[j] == x[j + 1]);
				assert(y[j] != y[j + 1]);
				assert(x[i] != x[i + 1]);
				if (between(y[i], minmax(y[j], y[j + 1])) &&
					between(x[j], minmax(x[i], x[i + 1]))) {
					return false;
				}
			}
		}
		for (int i = 0; i + 1 < n * 2; i += 2) {
			for (int j = i + 2; j + 1 < n * 2; j += 2) {
				assert(y[i] == y[i + 1]);
				assert(y[j] == y[j + 1]);
				assert(x[i] != x[i + 1]);
				assert(x[j] != x[j + 1]);
				if (y[i] == y[j] && (between(x[i], minmax(x[j], x[j + 1])) ||
							between(x[i + 1], minmax(x[j], x[j + 1])) ||
							between(x[j], minmax(x[i], x[i + 1])) ||
							between(x[j + 1], minmax(x[i], x[i + 1])))) {
					return false;
				}
			}
		}
		for (int i = 1; i + 1 < n * 2; i += 2) {
			for (int j = i + 2; j + 1 < n * 2; j += 2) {
				assert(x[i] == x[i + 1]);
				assert(x[j] == x[j + 1]);
				assert(y[i] != y[i + 1]);
				assert(y[j] != y[j + 1]);
				if (x[i] == x[j] && (between(y[i], minmax(y[j], y[j + 1])) ||
							between(y[i + 1], minmax(y[j], y[j + 1])) ||
							between(y[j], minmax(y[i], y[i + 1])) ||
							between(y[j + 1], minmax(y[i], y[i + 1])))) {
					return false;
				}
			}
		}
		return true;
	};


	auto start = high_resolution_clock::now();
	for (;;) {
		auto stop = high_resolution_clock::now();
		auto duration = duration_cast<milliseconds>(stop - start);
		if (duration >= 950ms) break;
		cur[rand() % (n - 1)] = rand() % 50 + 1;
		if (test()) {
			cout << "YES" << '\n';
			for (auto u : cur) cout << u << " ";
			cout << "\n";
			exit(0);
		}
	};

	cout << "NO" << '\n';
}

Test details

Test 1

Group: 1, 2, 4, 5

Verdict: ACCEPTED

input
2
2 10
D

correct output
YES

user output
YES
34 

Test 2

Group: 1, 2, 4, 5

Verdict:

input
8
5 8 7 5 6 5 3 4
DUUUDDD

correct output
YES
1 5 1 1 3 1 1 

user output
YES
22 42 7 47 13 14 13 

Test 3

Group: 1, 2, 4, 5

Verdict:

input
8
9 8 8 10 10 8 9 10
DDDUUUD

correct output
YES
1 1 1 4 1 1 7 

user output
YES
1 1 1 44 34 28 1 

Test 4

Group: 1, 2, 4, 5

Verdict:

input
8
9 10 8 8 9 9 7 8
DDDDUUU

correct output
NO

user output
YES
23 31 47 21 43 10 6 

Test 5

Group: 1, 2, 4, 5

Verdict:

input
8
10 2 8 3 10 2 10 10
DDUUUUD

correct output
YES
1 1 3 1 1 1 7 

user output
YES
1 1 1 1 34 28 1 

Test 6

Group: 2, 4, 5

Verdict:

input
15
73 74 97 82 19 50 26 51 56 93 ...

correct output
YES
1 2 3 1 1 3 1 1 1 10 1 3 1 1 

user output
YES
2 20 39 16 22 41 13 29 38 41 1...

Test 7

Group: 2, 4, 5

Verdict: ACCEPTED

input
15
95 71 97 77 98 76 100 62 96 69...

correct output
YES
1 1 3 1 1 1 1 1 9 1 11 1 13 1 

user output
YES
18 5 49 33 33 18 48 45 3 4 38 ...

Test 8

Group: 2, 4, 5

Verdict:

input
15
79 81 84 86 88 90 92 92 91 89 ...

correct output
YES
1 2 3 4 5 6 14 1 6 5 4 3 2 1 

user output
YES
21 44 30 15 48 3 49 4 39 19 18...

Test 9

Group: 2, 4, 5

Verdict:

input
15
97 90 87 83 79 76 74 23 24 76 ...

correct output
YES
13 11 9 7 5 3 1 1 3 5 7 9 11 1...

user output
NO

Test 10

Group: 2, 4, 5

Verdict:

input
15
100 2 99 1 78 4 93 2 100 1 15 ...

correct output
NO

user output
YES
27 5 49 33 33 37 27 14 40 4 38...

Test 11

Group: 4, 5

Verdict:

input
1000
999997 999995 999993 999991 99...

correct output
YES
997 995 993 991 989 987 985 98...

user output
NO

Test 12

Group: 5

Verdict:

input
100000
999999998 999999996 999999994 ...

correct output
YES
99997 99995 99993 99991 99989 ...

user output
NO

Test 13

Group: 3, 4, 5

Verdict:

input
1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
YES
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

user output
NO

Test 14

Group: 3, 4, 5

Verdict: ACCEPTED

input
1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
NO

user output
NO

Test 15

Group: 1, 2, 4, 5

Verdict: ACCEPTED

input
5
6 7 7 6 6
UDUU

correct output
YES
1 4 1 1 

user output
YES
1 50 34 11 

Test 16

Group: 4, 5

Verdict:

input
30
15 12 9 88 10 26 78 23 67 14 9...

correct output
YES
1 1 1 4 1 3 1 1 7 1 19 1 1 3 1...

user output
YES
42 43 15 21 42 21 1 49 47 5 49...

Test 17

Group: 4, 5

Verdict:

input
1000
1000000 1 146324 146324 289287...

correct output
YES
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

user output
NO

Test 18

Group: 5

Verdict:

input
100000
1000000000 1 421262579 4212625...

correct output
YES
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

user output
(empty)

Test 19

Group: 1, 2, 4, 5

Verdict: ACCEPTED

input
8
1 3 1 2 5 1 1 2
DUUUDUU

correct output
NO

user output
NO

Test 20

Group: 2, 4, 5

Verdict:

input
15
3 1 33 13 1 11 32 8 1 19 15 25...

correct output
YES
1 1 5 1 1 3 5 1 1 1 1 5 2 1 

user output
YES
6 42 28 9 14 22 42 22 5 2 6 7 ...

Test 21

Group: 2, 4, 5

Verdict:

input
15
10 2 39 41 42 34 31 28 26 24 2...

correct output
YES
1 1 1 1 10 9 8 7 6 1 4 1 1 1 

user output
NO

Test 22

Group: 2, 4, 5

Verdict:

input
15
27 4 6 23 26 37 40 38 44 27 3 ...

correct output
YES
1 1 1 1 5 1 7 1 3 1 1 3 1 1 

user output
YES
14 1 37 50 34 13 1 1 41 1 1 41...

Test 23

Group: 4, 5

Verdict:

input
1000
3246 3562 197273 197429 197755...

correct output
YES
1 1 1 4 5 10 3 1 1 3 7 12 1 1 ...

user output
NO

Test 24

Group: 4, 5

Verdict:

input
1000
503981 503487 503350 502673 50...

correct output
YES
999 1 997 1 1 994 989 1 1 1 1 ...

user output
NO

Test 25

Group: 4, 5

Verdict: ACCEPTED

input
1000
1445 1363 1749 1084 262408 263...

correct output
NO

user output
NO

Test 26

Group: 5

Verdict: ACCEPTED

input
100000
209655 9167 9389 191291 198294...

correct output
NO

user output
NO

Test 27

Group: 5

Verdict:

input
100000
16295 14904 5103 13337 26939 3...

correct output
YES
1 1 1 1 5 6 1 1 1 10 11 1 13 1...

user output
NO

Test 28

Group: 5

Verdict:

input
100000
1859 174288 15040 4631 4993844...

correct output
YES
1 3 1 1 99997 99992 1 1 5 1 1 ...

user output
NO

Test 29

Group: 5

Verdict:

input
100000
959817 958289 966165 922369 92...

correct output
YES
1 1 1 1 1 1 1 1 1 1 11 14 1 1 ...

user output
NO

Test 30

Group: 1, 2, 4, 5

Verdict:

input
8
2 3 2 3 5 6 7 8
UDDDUDU

correct output
YES
1 2 1 1 5 6 7 

user output
YES
14 41 37 50 41 13 1