1733E - Conveyor - CodeForces Solution


constructive algorithms dp math *2700

Please click on ads to support us..

C++ Code:

#include <iostream>

using namespace std;

long long c[120][120];
long long v[120][120];

int main() {
    int q;
    cin >> q;
    for (int k=0; k<q; k++) {
        //cout << k << " " << q << endl;
        long long t,xq,yq;
        cin >> t >> xq >> yq;
        for (int i=0; i<120; i++) {
            for (int j=0; j<120; j++) {
                c[i][j] = 0;
                v[i][j] = 0;
            }
        }
        if (xq+yq>t) {
            cout << "NO\n";
            continue;
        }
        v[0][0] = t-xq-yq;
        for (int i=0; i<120; i++) {
            for (int j=0; j<120; j++) {
                if (v[i][j]%2) {
                    c[i][j] = 1;
                }else{
                    c[i][j] = 0;
                }
                if (i!=119) {
                    v[i+1][j] += v[i][j]-(v[i][j]/2);
                }
                if (j!=119) {
                    v[i][j+1] += v[i][j]/2;
                }
            }
        }
        long long x = 0;
        long long y = 0;
        for (int i=0; i<xq+yq; i++) {
            if (x==120||y==120) {
                break;
            }
            if (c[x][y]==1) {
                y++;
            }else{
                x++;
            }
            //cout << x << " " << y << endl;
        }
        if (y==xq&&x==yq) {
            cout << "YES\n";
        }else{
            cout << "NO\n";
        }
    }
}


Comments

Submit
0 Comments
More Questions

32. Longest Valid Parentheses
Cutting a material
Bubble Sort
Number of triangles
AND path in a binary tree
Factorial equations
Removal of vertices
Happy segments
Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement