QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#809241#2526. Imprecise ComputerSGColinAC ✓12ms3688kbC++201.2kb2024-12-11 13:27:442024-12-11 13:27:44

Judging History

This is the latest submission verdict.

  • [2024-12-11 13:27:44]
  • Judged
  • Verdict: AC
  • Time: 12ms
  • Memory: 3688kb
  • [2024-12-11 13:27:44]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

inline int rd() {
	int x = 0;
	bool f = 0;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) f |= (c == '-');
	for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
	return f ? -x : x;
}

#define N 1000007
#define pb push_back
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)

// 0 : ll -> 2
// 1 : lw -> 1
// 2 : ww -> 0

int main() {
	int n = rd();
	bool old[3] = {0, 0, 0};
	int x = rd();
	if (x > 1) {puts("NO"); return 0;}
	if (x) old[1] = true;
	else old[0] = old[2] = true;
	rep(i, 2, n - 1) {
		x = rd();
		if (x > 2) {puts("NO"); return 0;}
		bool nw[3] = {0, 0, 0};
		if (x == 0) {
			if (old[0] || old[2]) nw[0] = nw[2] = true;
			if (old[1]) nw[1] = true;
		} else if (x == 1) {
			if (old[1]) nw[0] = nw[2] = true;
			if (old[0] || old[2]) nw[1] = true;
		} else {
			if (old[1]) nw[1] = true;
		}
		rep(j, 0, 2) old[j] = nw[j];
	}
	x = rd();
	if (x > 1) {puts("NO"); return 0;}
	if (x == 1){
		if (old[1]) puts("YES");
		else puts("NO");
	} else {
		if (old[0] || old[2]) puts("YES");
		else puts("NO");
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

10
1 2 3 3 3 3 2 1 2 2

output:

NO

result:

ok single line: 'NO'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3500kb

input:

10
0 0 0 0 0 0 0 0 0 1

output:

NO

result:

ok single line: 'NO'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

10
0 1 0 1 0 1 0 1 0 1

output:

NO

result:

ok single line: 'NO'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

10
1 0 1 0 1 0 1 0 1 0

output:

NO

result:

ok single line: 'NO'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

10
1 2 2 2 2 2 2 2 0 1

output:

YES

result:

ok single line: 'YES'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

10
1 2 2 2 2 2 2 2 0 0

output:

NO

result:

ok single line: 'NO'

Test #7:

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

input:

1000000
0 1 2 1 0 1 2 1 0 1 1 1 0 0 1 0 1 1 1 0 1 0 0 0 0 1 1 1 1 0 1 0 1 0 1 1 0 1 2 0 0 1 1 2 2 0 2 0 2 1 1 0 2 2 0 0 2 1 0 0 0 1 0 2 1 1 1 0 1 0 1 1 1 0 1 1 1 2 1 0 0 0 1 0 1 0 0 1 0 1 1 0 1 1 0 2 2 1 1 0 2 0 2 2 1 1 1 0 1 2 1 0 1 0 1 0 0 1 1 0 0 1 2 0 2 1 1 1 0 1 0 1 0 0 0 0 0 1 2 1 1 0 0 1 0 1 ...

output:

NO

result:

ok single line: 'NO'

Test #8:

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

input:

1000000
1 0 0 0 2 0 2 2 1 1 0 2 0 0 0 1 0 1 1 1 2 2 2 2 1 0 0 1 2 1 1 0 0 0 2 0 0 0 2 2 2 1 1 0 0 0 0 1 0 0 0 0 1 1 0 1 1 0 0 1 0 0 2 1 1 1 0 0 0 1 2 2 0 0 0 0 2 2 2 1 1 0 0 1 0 1 1 1 0 2 1 1 0 2 1 1 1 1 1 0 0 0 1 2 1 1 1 1 1 0 1 2 2 0 2 1 1 0 2 0 0 1 1 2 2 2 0 1 1 2 0 0 0 0 1 0 0 0 0 1 0 0 1 0 1 2 ...

output:

NO

result:

ok single line: 'NO'

Test #9:

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

input:

1000000
1 2 0 0 0 1 1 1 0 1 2 2 2 0 0 1 0 1 2 1 0 0 0 0 0 1 1 1 0 1 0 1 1 1 2 0 1 0 1 1 1 0 2 2 2 1 0 1 1 1 2 2 0 0 0 0 0 0 2 0 0 1 0 0 1 2 0 2 0 1 0 0 1 1 0 1 1 0 1 0 2 2 0 1 0 0 0 0 0 1 1 1 0 2 0 2 2 0 1 1 0 1 0 1 1 0 0 1 0 0 0 2 2 2 1 0 1 2 1 1 0 0 2 0 1 1 2 2 2 1 1 0 2 1 0 1 1 0 1 1 0 0 1 0 2 0 ...

output:

YES

result:

ok single line: 'YES'

Test #10:

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

input:

1000000
0 0 0 0 0 1 2 2 2 1 1 1 0 1 0 2 1 0 0 1 0 1 0 0 0 1 0 0 1 0 0 0 1 2 0 2 2 2 0 0 0 0 0 2 0 1 0 1 0 2 0 0 2 2 2 0 1 0 1 0 0 0 2 0 0 1 0 0 1 1 1 0 1 1 0 2 1 1 2 1 1 1 1 2 1 1 0 0 1 0 1 2 2 1 0 0 0 0 1 0 1 1 0 2 1 1 2 1 1 1 0 0 1 2 2 1 1 1 1 0 2 2 2 2 1 1 2 1 0 0 1 1 1 2 1 1 2 1 0 0 0 0 0 0 0 1 ...

output:

NO

result:

ok single line: 'NO'

Test #11:

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

input:

1000000
1 1 1 0 2 2 2 0 0 1 0 0 0 1 0 1 0 1 0 1 1 2 0 2 2 0 0 1 1 0 2 1 0 1 0 1 0 1 0 2 2 0 1 0 1 0 2 1 0 0 0 0 1 1 0 1 0 1 0 0 0 1 1 1 0 0 1 1 0 1 1 1 1 1 0 0 1 1 1 2 0 1 0 0 1 0 1 1 1 1 0 1 0 1 2 0 2 1 0 1 0 1 0 0 0 1 0 1 1 0 1 0 0 0 1 1 0 0 1 0 2 1 1 0 1 0 1 1 0 1 1 0 1 0 0 1 0 1 2 2 2 2 1 1 2 0 ...

output:

YES

result:

ok single line: 'YES'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

10
2 1 1 1 1 1 1 1 1 1

output:

NO

result:

ok single line: 'NO'

Test #13:

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

input:

1000000
1 2 0 0 1 1 1 0 1 2 1 0 0 1 0 1 0 1 2 2 0 0 1 1 0 1 1 2 0 1 0 1 0 2 2 2 2 0 2 0 2 1 1 0 1 1 1 0 1 0 0 2 1 0 0 1 1 0 1 0 1 1 2 0 1 1 0 1 0 0 1 1 0 1 2 0 0 1 0 0 1 1 0 0 1 2 1 0 0 0 0 1 1 1 0 1 1 1 1 0 0 2 0 0 2 1 0 1 1 0 0 1 1 1 0 0 1 1 2 1 1 1 1 0 2 0 1 1 1 0 0 0 0 0 0 1 2 1 1 0 2 1 0 0 1 0 ...

output:

YES

result:

ok single line: 'YES'

Test #14:

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

input:

1000000
1 0 0 0 2 0 0 1 1 1 1 0 1 1 0 1 0 1 0 1 1 0 0 1 1 1 0 1 1 0 1 2 0 1 0 0 0 1 2 0 1 1 2 1 1 0 1 1 2 2 1 1 2 2 1 0 1 1 1 0 0 2 2 2 1 0 1 2 2 0 0 0 1 1 1 0 0 0 0 1 0 0 0 2 1 1 1 1 0 1 1 2 0 1 1 0 1 1 2 2 2 0 2 1 1 1 1 2 1 0 1 1 0 1 0 1 1 0 0 2 0 0 0 2 2 0 2 1 1 0 0 2 1 1 2 1 0 1 1 1 1 0 1 0 0 0 ...

output:

NO

result:

ok single line: 'NO'

Test #15:

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

input:

1000000
1 2 2 0 0 1 0 1 2 1 1 0 2 1 0 1 1 1 1 0 1 1 0 0 1 0 2 1 1 1 1 1 0 1 1 1 0 1 0 0 0 1 2 0 1 0 1 2 1 1 0 0 0 1 1 2 0 1 1 2 1 0 1 0 0 2 1 0 1 1 1 1 1 2 0 0 2 1 1 2 1 1 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 1 2 0 0 0 0 0 1 1 1 1 1 0 0 0 1 0 0 1 1 1 1 2 0 1 0 0 0 1 1 1 0 0 2 1 0 0 1 0 0 ...

output:

NO

result:

ok single line: 'NO'

Test #16:

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

input:

1000000
1 0 2 0 1 1 2 0 1 0 0 1 0 2 0 1 0 1 2 2 1 1 0 2 1 1 2 0 1 1 0 1 1 2 0 2 1 0 0 1 1 1 0 1 0 0 0 0 0 0 1 0 2 2 0 0 2 0 2 1 0 1 0 0 2 0 1 0 1 0 2 0 1 1 1 0 1 1 1 1 0 1 0 0 0 2 1 0 1 1 0 0 1 0 0 2 0 1 1 0 0 1 0 0 0 1 2 2 2 2 2 0 0 2 0 0 0 0 2 0 0 0 0 1 0 1 0 1 0 1 1 0 1 2 2 0 1 0 0 0 0 0 1 0 0 0 ...

output:

YES

result:

ok single line: 'YES'

Test #17:

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

input:

1000000
1 2 1 0 0 1 2 0 1 0 1 0 2 0 0 1 0 1 1 0 1 2 2 1 0 0 0 1 1 0 0 0 1 1 0 0 0 0 0 1 2 1 0 1 0 2 0 2 0 2 2 0 0 1 0 1 1 0 0 1 1 0 1 1 1 1 1 2 2 2 0 1 0 0 0 1 0 0 0 1 1 2 0 1 0 1 0 2 0 2 0 0 1 0 1 1 0 0 1 0 2 0 1 0 0 1 2 2 1 1 1 0 1 1 1 2 1 0 1 1 1 2 0 2 1 0 1 2 2 1 1 1 1 2 0 2 0 1 1 0 1 0 0 1 0 0 ...

output:

NO

result:

ok single line: 'NO'

Test #18:

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

input:

1000000
1 1 1 0 0 2 2 2 1 0 0 1 0 1 0 0 1 1 0 0 0 0 0 0 0 1 2 0 1 0 0 1 2 0 0 1 1 0 0 0 1 1 1 0 0 1 0 2 0 1 0 0 1 2 0 1 1 1 0 1 1 0 0 1 0 2 0 2 0 1 0 1 1 0 1 0 2 0 2 0 2 1 0 1 2 2 1 0 1 0 0 0 2 2 0 0 0 0 1 1 1 1 1 1 0 0 0 2 0 0 0 2 2 2 1 1 0 0 1 1 2 0 0 0 0 0 2 1 1 1 1 2 2 0 1 1 2 2 2 0 1 0 1 2 0 0 ...

output:

NO

result:

ok single line: 'NO'

Test #19:

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

input:

1000000
1 2 2 1 1 1 0 0 1 2 1 0 0 1 2 0 1 1 0 2 1 0 1 2 2 2 1 1 1 0 0 0 1 0 0 0 0 1 1 2 2 2 2 0 2 1 1 0 0 1 0 1 2 2 1 1 1 1 2 2 0 1 0 0 0 1 2 1 0 1 1 1 1 0 0 0 1 0 2 1 0 1 2 1 0 0 0 1 1 1 1 1 1 0 0 0 1 2 2 1 0 1 1 0 0 1 2 0 1 1 2 2 1 0 0 0 0 0 0 0 1 0 2 0 0 1 0 0 0 0 0 1 2 1 0 0 0 0 1 1 0 1 1 1 1 0 ...

output:

NO

result:

ok single line: 'NO'

Test #20:

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

input:

1000000
1 1 1 1 0 1 0 1 1 2 0 1 1 2 2 2 1 1 1 1 0 0 2 1 1 1 1 1 0 0 0 0 1 2 2 0 1 1 1 0 1 1 1 2 2 2 1 0 1 2 0 2 0 1 0 1 0 1 0 0 1 2 2 0 2 1 0 0 0 1 2 1 0 1 0 0 0 0 2 1 1 2 2 2 2 0 0 1 1 1 1 2 2 0 1 1 1 1 0 0 0 0 2 0 0 1 0 1 0 0 1 1 1 0 0 1 2 2 1 1 1 1 2 1 1 0 1 0 0 1 2 2 0 2 0 0 1 0 1 0 0 2 1 0 0 1 ...

output:

NO

result:

ok single line: 'NO'

Test #21:

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

input:

1000000
1 0 1 1 0 2 0 1 0 0 1 1 1 0 2 2 2 0 2 2 2 1 0 1 0 0 0 0 1 1 1 1 0 1 1 2 2 2 2 1 1 0 0 0 2 2 1 0 0 0 1 2 2 2 0 1 1 0 1 0 1 0 1 1 1 1 1 0 0 1 0 2 1 1 2 2 2 0 1 1 1 0 0 1 2 0 1 1 0 0 0 0 2 1 0 1 2 2 0 2 2 2 2 1 0 1 0 0 2 2 0 1 0 1 1 1 1 1 0 2 1 0 1 2 1 1 0 0 2 1 1 0 2 0 1 1 0 0 0 2 0 0 1 0 0 1 ...

output:

NO

result:

ok single line: 'NO'

Test #22:

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

input:

1000000
1 2 1 0 0 0 0 0 1 2 2 1 1 1 1 2 0 2 0 1 1 2 0 2 0 2 0 1 0 0 0 1 1 1 1 0 1 2 0 0 0 2 0 2 1 1 1 1 1 1 2 2 0 0 2 2 1 1 2 2 1 0 1 0 0 0 0 0 1 1 1 1 2 0 1 0 1 0 1 0 1 0 2 0 1 1 0 0 1 0 0 1 2 2 2 2 0 0 1 1 1 0 0 1 2 1 1 0 0 1 0 0 1 2 0 1 1 2 0 0 1 1 2 0 0 0 2 2 1 0 1 0 1 0 1 2 2 2 2 2 2 1 0 0 0 0 ...

output:

NO

result:

ok single line: 'NO'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

10
1 1 1 1 1 1 1 1 1 2

output:

NO

result:

ok single line: 'NO'

Test #24:

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

input:

1000000
1 0 0 1 1 0 0 0 1 1 1 0 0 0 1 2 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 0 1 2 1 0 0 1 1 1 2 1 1 0 1 1 0 1 1 2 2 2 2 2 0 0 0 2 0 0 1 1 2 1 0 1 0 0 2 0 2 2 0 0 0 1 0 1 0 2 1 0 0 0 1 2 2 0 2 2 2 0 0 0 1 1 1 0 1 1 0 1 0 2 2 1 0 1 2 0 1 0 0 1 2 1 0 0 0 0 1 0 2 2 2 1 1 0 0 0 2 1 1 1 1 1 0 1 1 1 2 2 1 0 0 1 ...

output:

NO

result:

ok single line: 'NO'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

10
1 2 2 2 2 2 2 2 2 0

output:

NO

result:

ok single line: 'NO'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

10
1 2 2 2 2 2 2 2 2 1

output:

YES

result:

ok single line: 'YES'

Test #27:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

10
1 1 1 1 1 1 1 1 1 1

output:

YES

result:

ok single line: 'YES'

Test #28:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

9
1 1 1 1 1 1 1 1 1

output:

NO

result:

ok single line: 'NO'

Test #29:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

10
0 0 0 0 0 0 0 0 0 0

output:

YES

result:

ok single line: 'YES'

Test #30:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

10
0 0 0 0 0 0 0 0 1 1

output:

YES

result:

ok single line: 'YES'

Test #31:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

5
1 0 2 0 1

output:

YES

result:

ok single line: 'YES'

Test #32:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

5
1 1 2 1 0

output:

NO

result:

ok single line: 'NO'