Submission #414882

# Submission time Handle Problem Language Result Execution time Memory
414882 2021-05-31T10:00:15 Z shivensinha4 CATS (NOI14_cats) C++17
0 / 25
1500 ms 262148 KB
#include <bits/stdc++.h>
using namespace std;
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef array<int, 2> ii;
//#define endl '\n'

void show(vector<ll> &a) {
    int pt = a.size();
    for_(i, 0, a.size()) if (a[i] != 0) {
        pt = i;
        break;
    }
    for_(i, pt, a.size()) cout << a[i] << " ";
    cout << endl;
}

int main() {
#ifdef mlocal
    freopen("test.in", "r", stdin);
//    freopen("test.out", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t; cin >> t;
    while (t--) {
        ll x, l, n; cin >> x >> l >> n;
        vector<ll> s1, s2;
        for_(i, 0, l) {
            s1.push_back(0); s2.push_back(0);
        }

        int pt = 0;
        while (x) {
            pt++;
            s2.push_back(s1.back());
            s1.pop_back();

            for_(i, 0, s1.size()) s1[i] = s1[i]^1;
//            cout << "S1: "; show(s1);

            if (s2.back() > l) {
//                cout << "---------------------" << endl;
//                cout << "iteration " << pt << endl;
//                cout << "decrementeed!" << endl;
//                cout << "S2: "; show(s2);
                x--;
            }
            else {
                s2[s2.size()-1] += 2*n; // push N, push N, add, add
                s1.push_back(s2.back());
                s1.push_back(s2.back());
                s2.pop_back(); s2.pop_back();
            }

//            cout << "S1: "; show(s1);
//            cout << "S2: "; show(s2);
        }

        cout << s2.back() << endl;
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 940 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1360 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1360 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1592 ms 2108 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 338 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 315 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -