QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#233152#2526. Imprecise ComputerBUET_Twilight#WA 0ms3716kbC++231.9kb2023-10-31 14:10:162023-10-31 14:10:16

Judging History

This is the latest submission verdict.

  • [2023-10-31 14:10:16]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3716kb
  • [2023-10-31 14:10:16]
  • Submitted

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
#define int long long
#define ll long long 
#define lll __int128_t
#define pb push_back
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
void solve() {
    int n; cin >> n;
    int a[n + 1];
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    
    if(a[1] == 2) {
        cout << "NO\n";
        return;
    }

    int r1 = 0;
    int r2 = 0;
    if(a[1] == 0) r1 = 1, r2 = 1;
    else r1 = 1, r2 = 0;
    for(int i = 2; i <= n; i++) {
        int cr1 = 1 - r1;
        int cr2 = 1 - r2;
        if(cr1 == cr2) {
            if(a[i] == 2) {
                cout << "NO\n";
                return;
            }
            else {
                if(a[i] == 0) r1 = 1, r2 = 1;
                else r1 = 1, r2 = 0;
            }
        }
        else {
            if(a[i] == 2) {
                if(cr1 == 1) r1 = 1, r2 = 0;
                else r1 = 0, r2 = 1;
            }
            else {
                if(a[i] == 0) {
                    if(cr1 == 1) r1 = 0, r2 = 1;
                    else r1 = 1, r2 = 0;
                }
                else {
                    r1 = 1, r2 = 1;
                }
            }
        }
    }
    cout << "YES\n";
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

10
1 2 3 3 3 3 2 1 2 2

output:

NO

result:

ok single line: 'NO'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3716kb

input:

10
0 0 0 0 0 0 0 0 0 1

output:

YES

result:

wrong answer 1st lines differ - expected: 'NO', found: 'YES'