Submission #66165332


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

bool check(int x, int y, int z) {
    vector<int> a;
    for(int i = 1; i <= x; i++) a.push_back(0);
    for(int i = 1; i <= y; i++) a.push_back(1);
    for(int i = 1; i <= z; i++) a.push_back(2);
    const int n = x + y + z;
    bool good = false;
    do {
        bool cur = true;
        for(int i = 0; i < n; i++) {
            int l = ((i - 1) % n + n) % n;
            int r = (i + 1) % n;
            if(a[i] == 0) continue;
            if(a[i] == 1) {
                if(a[l] < a[i] && a[r] < a[i]) {
                    cur = false;
                    break;
                }
                if(a[l] < a[i] || a[r] < a[i]) {
                    continue;
                }
                cur = false;
                break;
            } else {
                if(a[l] < a[i] && a[r] < a[i]) continue;
                cur = false;
                break;
            }
        }
        good |= cur;
    } while(next_permutation(a.begin(), a.end()));
    return good;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // freopen("out.txt", "r", stdin);
    // freopen("out2.txt", "w", stdout);
    int T;
    cin >> T;
    while(T--) {
        int x, y, z;
        cin >> x >> y >> z;
        int need = y / 2;
        // bool correct = check(x, y, z);
        // cout << correct << " ";
        need = min(need, z);
        if(x < need) {
            cout << "No\n";
            continue;
        }
        bool had_two = need > 0;
        x -= need;
        z -= need;
        y -= 2 * need;
        need = y / 2;
        if(x < need) {
            cout << "No\n";
            continue;
        }
        if(z && y) {
            had_two = true;
            z--;
        }
        x -= need;
        y -= 2 * need;
        // cout << x << " " << y << " " << z << '\n';
        if(y) {
            if(!had_two) {
                cout << "No\n";
                continue;
            }
            x--, y--;
        }
        if(x < z) {
            cout << "No\n";
            continue;
        }
        z -= min(z, x);
        if(y == 0 && z == 0) cout << "Yes\n";
        else cout << "No\n";
    }
}

Submission Info

Submission Time
Task B - Rivalry
User Wasif_Shahzad
Language C++ 20 (gcc 12.2)
Score 500
Code Size 2378 Byte
Status AC
Exec Time 38 ms
Memory 3592 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 1
AC × 11
Set Name Test Cases
Sample example_00.txt
All example_00.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3564 KiB
test_00.txt AC 22 ms 3592 KiB
test_01.txt AC 37 ms 3516 KiB
test_02.txt AC 37 ms 3464 KiB
test_03.txt AC 37 ms 3520 KiB
test_04.txt AC 37 ms 3576 KiB
test_05.txt AC 37 ms 3524 KiB
test_06.txt AC 38 ms 3576 KiB
test_07.txt AC 36 ms 3520 KiB
test_08.txt AC 36 ms 3372 KiB
test_09.txt AC 36 ms 3456 KiB