QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#672204 | #2526. Imprecise Computer | NYCU_CartesianTree | AC ✓ | 36ms | 7596kb | C++20 | 848b | 2024-10-24 16:01:05 | 2024-10-24 16:01:05 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int const N = 1e6 + 5;
int a[N];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
// ifstream f1("in.txt");
int first = 0, last = 0, cnt = 0;
for(int i = 1; i <= n; i++){
cin >> a[i];
if(a[i]==2&&cnt%2==0){
cout<<"NO\n";
return 0;
}
if(a[i] > 2){
cout << "NO\n";
return 0;
}
if(a[i] && !first){
if(a[i] == 2){
cout << "NO\n";
return 0;
}
first = 1;
}
if(a[i])
last = a[i];
if(a[i] == 1)
cnt++;
}
if(last == 2 || cnt % 2){
cout << "NO\n";
return 0;
}
cout << "YES\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3648kb
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: 3640kb
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: 3644kb
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: 3584kb
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: 3628kb
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: 3648kb
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: 35ms
memory: 7596kb
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: 31ms
memory: 7592kb
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: 32ms
memory: 7536kb
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: 35ms
memory: 7524kb
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: 35ms
memory: 7528kb
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: 3640kb
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: 36ms
memory: 7468kb
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: 1ms
memory: 3808kb
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: 1ms
memory: 3684kb
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: 32ms
memory: 7552kb
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: 2ms
memory: 3800kb
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: 1ms
memory: 3644kb
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: 1ms
memory: 3616kb
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: 4ms
memory: 5908kb
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: 0ms
memory: 3964kb
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: 3ms
memory: 3940kb
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: 3636kb
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: 3ms
memory: 3912kb
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: 3636kb
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: 3692kb
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: 3632kb
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: 3644kb
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: 3508kb
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: 3604kb
input:
5 1 0 2 0 1
output:
YES
result:
ok single line: 'YES'
Test #32:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
5 1 1 2 1 0
output:
NO
result:
ok single line: 'NO'