Submission #1041729

# Submission time Handle Problem Language Result Execution time Memory
1041729 2024-08-02T07:29:15 Z 정민찬(#11002) A Light Inconvenience (CEOI23_light) C++17
15 / 100
1000 ms 1376 KB
#include "light.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const ll goal = 5;
vector<ll> pos;
ll len;

void prepare(){
    pos.clear();
    pos.push_back(1);
    len = 1;
}

pair<ll, vector<ll>> join(ll p){
    len += p;
    vector<ll> S(len + 1, 0);
    for (auto &x : pos) {
        S[x] ++;
        if (x + p*goal + 1 <= len)
            S[x + p*goal + 1] --;
    }
    for (ll i=1; i<=len; i++) {
        S[i] += S[i-1];
    }
    vector<ll> nw;
    nw.push_back(len);
    ll prv = -1;
    for (ll i=len-1; i>=0; i--) {
        if (S[i]) prv = i;
        if (i == len - (len - nw.back() + 1)*2) {
            assert(prv != -1);
            nw.push_back(prv);
            prv = -1;
        }
    }
    if (nw.back() != 1) nw.push_back(1);
    reverse(nw.begin(), nw.end());
    pos = nw;
    return {p*goal, nw};
}

pair<ll, vector<ll>> leave(ll p){
    len -= p;
    vector<ll> S(len + 1, 0);
    for (auto &x : pos) {
        if (x <= len)
            S[x] ++;
        if (x + p*goal + 1 <= len)
            S[x + p*goal + 1] --;
    }
    for (ll i=1; i<=len; i++) {
        S[i] += S[i-1];
    }
    vector<ll> nw;
    nw.push_back(len);
    ll prv = -1;
    for (ll i=len-1; i>=0; i--) {
        if (S[i]) prv = i;
        if (i == len - (len - nw.back() + 1)*2) {
            assert(prv != -1);
            nw.push_back(prv);
            prv = -1;
        }
    }
    if (nw.back() != 1) nw.push_back(1);
    reverse(nw.begin(), nw.end());
    pos = nw;
    return {p*goal, nw};
}
/*
using namespace std;
typedef long long ll;

namespace {

double maxQuotient = 0.0;
ll N = 1;
size_t maxFires = 1;
vector<ll> fires = {1};
constexpr int MAX_NUM_FIRES = 150;

[[noreturn]] void die(string msg)
{
    cout << msg << endl;
    exit(0);
}

void check(ll p, pair<ll, vector<ll>> res) {
    ll t = res.first;
    vector<ll> newFires = res.second;
    maxQuotient = max(maxQuotient, static_cast<double>(t)/abs(static_cast<double>(p)));
    maxFires = max(maxFires, newFires.size());

    cout << (p < 0? "leave" : "join") << "(" << llabs(p) << ") returned " << t << ", {";
    for(size_t i = 0; i < newFires.size(); i++) {
        cout << newFires[i];
        if(i + 1 < newFires.size()) cout << ", ";
    }
    cout << "}" << endl;

    if(t < 0 || t > 5 * static_cast<__int128_t>(llabs(p))) die("Invalid return value");
    for(size_t i = 0; i + 1 < newFires.size(); i++) {
        if(newFires[i] >= newFires[i + 1]) die("Invalid return value");
    }
    if(!newFires.empty() && (newFires[0] <= 0 || newFires.back() > N)) die("Invalid return value");
    if(newFires.size() > MAX_NUM_FIRES) die("Too many burning torches");
    if(newFires.empty() || newFires.back() < N) die("Rightmost torch not on fire");


    size_t i = 0;
    for (ll x : newFires) {
        for (;; ++i) {
            if (i >= fires.size() || fires[i] > x) die("Not all announced torches have been lit");
            if (fires[i] + t >= x) break;
        }
    }
    fires = newFires;
}

};

int main() {
    int Q;
    if (!(cin >> Q)) die("Invalid input");

    cout << "prepare()" << endl;
    prepare();

    for (int i = 0; i < Q; i++) {
        ll p;
        if (!(cin >> p) || p == 0) die("Invalid input");
        N += p;
        if (N <= 0) die("The stage is empty");
        if (p > 0)  check(p, join(p));
        if (p < 0)  check(p, leave(-p));
    }

    cout << "Correct: ratio at most " << maxQuotient << ", at most " << maxFires << " burning torches" << endl;
    return 0;
}*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 2 ms 684 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 259 ms 456 KB Output is correct
3 Correct 48 ms 476 KB Output is correct
4 Correct 290 ms 472 KB Output is correct
5 Correct 312 ms 340 KB Output is correct
6 Correct 8 ms 344 KB Output is correct
7 Correct 289 ms 468 KB Output is correct
8 Correct 15 ms 476 KB Output is correct
9 Correct 294 ms 456 KB Output is correct
10 Correct 290 ms 600 KB Output is correct
11 Correct 88 ms 1376 KB Output is correct
12 Correct 305 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 259 ms 456 KB Output is correct
3 Correct 48 ms 476 KB Output is correct
4 Correct 290 ms 472 KB Output is correct
5 Correct 312 ms 340 KB Output is correct
6 Correct 8 ms 344 KB Output is correct
7 Correct 289 ms 468 KB Output is correct
8 Correct 15 ms 476 KB Output is correct
9 Correct 294 ms 456 KB Output is correct
10 Correct 290 ms 600 KB Output is correct
11 Correct 88 ms 1376 KB Output is correct
12 Correct 305 ms 452 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 284 ms 344 KB Output is correct
15 Correct 40 ms 600 KB Output is correct
16 Correct 282 ms 344 KB Output is correct
17 Correct 292 ms 600 KB Output is correct
18 Correct 5 ms 344 KB Output is correct
19 Correct 266 ms 448 KB Output is correct
20 Correct 16 ms 472 KB Output is correct
21 Correct 287 ms 476 KB Output is correct
22 Correct 275 ms 344 KB Output is correct
23 Correct 74 ms 344 KB Output is correct
24 Correct 308 ms 344 KB Output is correct
25 Correct 8 ms 344 KB Output is correct
26 Correct 6 ms 344 KB Output is correct
27 Correct 11 ms 344 KB Output is correct
28 Correct 490 ms 480 KB Output is correct
29 Correct 25 ms 344 KB Output is correct
30 Correct 449 ms 492 KB Output is correct
31 Correct 467 ms 480 KB Output is correct
32 Correct 13 ms 600 KB Output is correct
33 Correct 471 ms 592 KB Output is correct
34 Correct 553 ms 472 KB Output is correct
35 Correct 452 ms 344 KB Output is correct
36 Correct 273 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 259 ms 456 KB Output is correct
3 Correct 48 ms 476 KB Output is correct
4 Correct 290 ms 472 KB Output is correct
5 Correct 312 ms 340 KB Output is correct
6 Correct 8 ms 344 KB Output is correct
7 Correct 289 ms 468 KB Output is correct
8 Correct 15 ms 476 KB Output is correct
9 Correct 294 ms 456 KB Output is correct
10 Correct 290 ms 600 KB Output is correct
11 Correct 88 ms 1376 KB Output is correct
12 Correct 305 ms 452 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 284 ms 344 KB Output is correct
15 Correct 40 ms 600 KB Output is correct
16 Correct 282 ms 344 KB Output is correct
17 Correct 292 ms 600 KB Output is correct
18 Correct 5 ms 344 KB Output is correct
19 Correct 266 ms 448 KB Output is correct
20 Correct 16 ms 472 KB Output is correct
21 Correct 287 ms 476 KB Output is correct
22 Correct 275 ms 344 KB Output is correct
23 Correct 74 ms 344 KB Output is correct
24 Correct 308 ms 344 KB Output is correct
25 Correct 8 ms 344 KB Output is correct
26 Correct 6 ms 344 KB Output is correct
27 Correct 11 ms 344 KB Output is correct
28 Correct 490 ms 480 KB Output is correct
29 Correct 25 ms 344 KB Output is correct
30 Correct 449 ms 492 KB Output is correct
31 Correct 467 ms 480 KB Output is correct
32 Correct 13 ms 600 KB Output is correct
33 Correct 471 ms 592 KB Output is correct
34 Correct 553 ms 472 KB Output is correct
35 Correct 452 ms 344 KB Output is correct
36 Correct 273 ms 344 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 278 ms 344 KB Output is correct
39 Correct 55 ms 344 KB Output is correct
40 Correct 293 ms 344 KB Output is correct
41 Correct 310 ms 344 KB Output is correct
42 Correct 7 ms 344 KB Output is correct
43 Correct 302 ms 344 KB Output is correct
44 Correct 24 ms 344 KB Output is correct
45 Correct 283 ms 344 KB Output is correct
46 Correct 280 ms 344 KB Output is correct
47 Correct 84 ms 968 KB Output is correct
48 Correct 284 ms 344 KB Output is correct
49 Correct 12 ms 600 KB Output is correct
50 Correct 6 ms 344 KB Output is correct
51 Correct 6 ms 344 KB Output is correct
52 Correct 474 ms 496 KB Output is correct
53 Correct 29 ms 600 KB Output is correct
54 Correct 479 ms 484 KB Output is correct
55 Correct 448 ms 480 KB Output is correct
56 Correct 11 ms 856 KB Output is correct
57 Correct 464 ms 480 KB Output is correct
58 Correct 567 ms 724 KB Output is correct
59 Correct 478 ms 344 KB Output is correct
60 Correct 296 ms 344 KB Output is correct
61 Correct 78 ms 600 KB Output is correct
62 Correct 222 ms 732 KB Output is correct
63 Correct 89 ms 684 KB Output is correct
64 Execution timed out 1410 ms 800 KB Time limit exceeded
65 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 259 ms 456 KB Output is correct
3 Correct 48 ms 476 KB Output is correct
4 Correct 290 ms 472 KB Output is correct
5 Correct 312 ms 340 KB Output is correct
6 Correct 8 ms 344 KB Output is correct
7 Correct 289 ms 468 KB Output is correct
8 Correct 15 ms 476 KB Output is correct
9 Correct 294 ms 456 KB Output is correct
10 Correct 290 ms 600 KB Output is correct
11 Correct 88 ms 1376 KB Output is correct
12 Correct 305 ms 452 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 284 ms 344 KB Output is correct
15 Correct 40 ms 600 KB Output is correct
16 Correct 282 ms 344 KB Output is correct
17 Correct 292 ms 600 KB Output is correct
18 Correct 5 ms 344 KB Output is correct
19 Correct 266 ms 448 KB Output is correct
20 Correct 16 ms 472 KB Output is correct
21 Correct 287 ms 476 KB Output is correct
22 Correct 275 ms 344 KB Output is correct
23 Correct 74 ms 344 KB Output is correct
24 Correct 308 ms 344 KB Output is correct
25 Correct 8 ms 344 KB Output is correct
26 Correct 6 ms 344 KB Output is correct
27 Correct 11 ms 344 KB Output is correct
28 Correct 490 ms 480 KB Output is correct
29 Correct 25 ms 344 KB Output is correct
30 Correct 449 ms 492 KB Output is correct
31 Correct 467 ms 480 KB Output is correct
32 Correct 13 ms 600 KB Output is correct
33 Correct 471 ms 592 KB Output is correct
34 Correct 553 ms 472 KB Output is correct
35 Correct 452 ms 344 KB Output is correct
36 Correct 273 ms 344 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 278 ms 344 KB Output is correct
39 Correct 55 ms 344 KB Output is correct
40 Correct 293 ms 344 KB Output is correct
41 Correct 310 ms 344 KB Output is correct
42 Correct 7 ms 344 KB Output is correct
43 Correct 302 ms 344 KB Output is correct
44 Correct 24 ms 344 KB Output is correct
45 Correct 283 ms 344 KB Output is correct
46 Correct 280 ms 344 KB Output is correct
47 Correct 84 ms 968 KB Output is correct
48 Correct 284 ms 344 KB Output is correct
49 Correct 12 ms 600 KB Output is correct
50 Correct 6 ms 344 KB Output is correct
51 Correct 6 ms 344 KB Output is correct
52 Correct 474 ms 496 KB Output is correct
53 Correct 29 ms 600 KB Output is correct
54 Correct 479 ms 484 KB Output is correct
55 Correct 448 ms 480 KB Output is correct
56 Correct 11 ms 856 KB Output is correct
57 Correct 464 ms 480 KB Output is correct
58 Correct 567 ms 724 KB Output is correct
59 Correct 478 ms 344 KB Output is correct
60 Correct 296 ms 344 KB Output is correct
61 Correct 78 ms 600 KB Output is correct
62 Correct 222 ms 732 KB Output is correct
63 Correct 89 ms 684 KB Output is correct
64 Execution timed out 1410 ms 800 KB Time limit exceeded
65 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 259 ms 456 KB Output is correct
3 Correct 48 ms 476 KB Output is correct
4 Correct 290 ms 472 KB Output is correct
5 Correct 312 ms 340 KB Output is correct
6 Correct 8 ms 344 KB Output is correct
7 Correct 289 ms 468 KB Output is correct
8 Correct 15 ms 476 KB Output is correct
9 Correct 294 ms 456 KB Output is correct
10 Correct 290 ms 600 KB Output is correct
11 Correct 88 ms 1376 KB Output is correct
12 Correct 305 ms 452 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 284 ms 344 KB Output is correct
15 Correct 40 ms 600 KB Output is correct
16 Correct 282 ms 344 KB Output is correct
17 Correct 292 ms 600 KB Output is correct
18 Correct 5 ms 344 KB Output is correct
19 Correct 266 ms 448 KB Output is correct
20 Correct 16 ms 472 KB Output is correct
21 Correct 287 ms 476 KB Output is correct
22 Correct 275 ms 344 KB Output is correct
23 Correct 74 ms 344 KB Output is correct
24 Correct 308 ms 344 KB Output is correct
25 Correct 8 ms 344 KB Output is correct
26 Correct 6 ms 344 KB Output is correct
27 Correct 11 ms 344 KB Output is correct
28 Correct 490 ms 480 KB Output is correct
29 Correct 25 ms 344 KB Output is correct
30 Correct 449 ms 492 KB Output is correct
31 Correct 467 ms 480 KB Output is correct
32 Correct 13 ms 600 KB Output is correct
33 Correct 471 ms 592 KB Output is correct
34 Correct 553 ms 472 KB Output is correct
35 Correct 452 ms 344 KB Output is correct
36 Correct 273 ms 344 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 278 ms 344 KB Output is correct
39 Correct 55 ms 344 KB Output is correct
40 Correct 293 ms 344 KB Output is correct
41 Correct 310 ms 344 KB Output is correct
42 Correct 7 ms 344 KB Output is correct
43 Correct 302 ms 344 KB Output is correct
44 Correct 24 ms 344 KB Output is correct
45 Correct 283 ms 344 KB Output is correct
46 Correct 280 ms 344 KB Output is correct
47 Correct 84 ms 968 KB Output is correct
48 Correct 284 ms 344 KB Output is correct
49 Correct 12 ms 600 KB Output is correct
50 Correct 6 ms 344 KB Output is correct
51 Correct 6 ms 344 KB Output is correct
52 Correct 474 ms 496 KB Output is correct
53 Correct 29 ms 600 KB Output is correct
54 Correct 479 ms 484 KB Output is correct
55 Correct 448 ms 480 KB Output is correct
56 Correct 11 ms 856 KB Output is correct
57 Correct 464 ms 480 KB Output is correct
58 Correct 567 ms 724 KB Output is correct
59 Correct 478 ms 344 KB Output is correct
60 Correct 296 ms 344 KB Output is correct
61 Correct 78 ms 600 KB Output is correct
62 Correct 222 ms 732 KB Output is correct
63 Correct 89 ms 684 KB Output is correct
64 Execution timed out 1410 ms 800 KB Time limit exceeded
65 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 344 KB Partially correct
2 Runtime error 2 ms 684 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -