답안 #124635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
124635 2019-07-03T15:53:17 Z johutha CATS (NOI14_cats) C++14
8 / 25
1500 ms 8260 KB
#include <vector>
#include <iostream>

#define int int64_t

using namespace std;

struct solver
{
    int x, l, n;
    vector<int> s1;
    vector<int> s2;

    void calc()
    {
        s1.resize(2, 0);
        s2.resize(2, 0);
        int ctr = 0;
        while (x > 0)
        {
            if (s1.size() == 0) s1.push_back(ctr);
            s2.push_back(s1.back());
            s1.pop_back();
            ctr += 1; ctr %= 2;
            for (int &i : s1)
            {
                i = i ^ 1;
            }
            if (s2.back() > l)
            {
                x--;
                if (x == 0) cout << s2.back() << "\n";
            }
            else
            {
                if (s2.size() == 0) s2.push_back(0);
                s2.back() += 2*n;
                s1.push_back(s2.back());
                s1.push_back(s2.back());
                if (s2.size() != 0) s2.pop_back();
                if (s2.size() != 0) s2.pop_back();
            }
        }
    }
};

signed main()
{
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);

    int q;
    cin >> q;

    for (int c = 0; c < q; c++)
    {
        solver s;
        cin >> s.x >> s.l >> s.n;
        s.calc();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 764 KB Output is correct
2 Correct 17 ms 4580 KB Output is correct
3 Correct 13 ms 2540 KB Output is correct
4 Correct 9 ms 1516 KB Output is correct
5 Correct 13 ms 4580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 512 ms 7960 KB Output is correct
2 Correct 382 ms 8260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1547 ms 7556 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1519 ms 780 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1539 ms 1580 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1524 ms 1784 KB Time limit exceeded
2 Halted 0 ms 0 KB -