답안 #414883

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
414883 2021-05-31T10:03:32 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, x+(2*l/n)+10) 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;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1549 ms 12840 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1576 ms 12840 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1594 ms 2008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1575 ms 6704 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 454 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 506 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -