UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#213078#2348. LifeOrigami_Tobiichi1007195ms124456kbC++116.9kb2024-11-09 19:16:142024-11-09 23:06:39

answer

#include <bits/stdc++.h>
using namespace std;
namespace Octane
{
// non terrae plus ultra
#define OCTANE
#define BUFFER_SIZE 100000
#define ll long long
#define db double
#define ldb long double
    char ibuf[BUFFER_SIZE], obuf[BUFFER_SIZE];
    char *p1 = ibuf, *p2 = ibuf, *p3 = obuf;
#ifdef ONLINE_JUDGE
#define getchar() ((p1 == p2) and (p2 = (p1 = ibuf) + fread(ibuf, 1, BUFFER_SIZE, stdin), p1 == p2) ? (EOF) : (*p1++))
#define putchar(x) ((p3 == obuf + BUFFER_SIZE) && (fwrite(obuf, p3 - obuf, 1, stdout), p3 = obuf), *p3++ = x)
#endif // fread in OJ, getchar in local

#define isdigit(ch) (ch > 47 && ch < 58)
#define isspace(ch) (ch < 33 && ch != EOF)

    const ll pow10[] = {
        (ll)1e0,
        (ll)1e1,
        (ll)1e2,
        (ll)1e3,
        (ll)1e4,
        (ll)1e5,
        (ll)1e6,
        (ll)1e7,
        (ll)1e8,
        (ll)1e9,
        (ll)1e10,
        (ll)1e11,
        (ll)1e12,
        (ll)1e13,
        (ll)1e14,
        (ll)1e15,
        (ll)1e16,
        (ll)1e17,
        (ll)1e18,
    };

    struct Octane_t
    {
        ~Octane_t()
        {
            fwrite(obuf, p3 - obuf, 1, stdout);
        }
        bool flag = false;
        operator bool()
        {
            return flag;
        }
    } io;

    template <typename T>
    inline T read()
    {
        T s = 0;
        int w = 1;
        char ch;
        while (ch = getchar(), !isdigit(ch) && (ch != EOF))
            if (ch == '-')
                w = -1;
        if (ch == EOF)
            return 0;
        while (isdigit(ch))
            s = s * 10 + ch - 48, ch = getchar();
        if (ch == '.')
        {
            ll flt = 0;
            int cnt = 0;
            while (ch = getchar(), isdigit(ch))
                if (cnt < 18)
                    flt = flt * 10 + ch - 48, cnt++;
            s += (db)flt / pow10[cnt];
        }
        return s *= w;
    }
    template <typename T>
    inline bool read(T &s)
    {
        s = 0;
        int w = 1;
        char ch;
        while (ch = getchar(), !isdigit(ch) && (ch != EOF))
            if (ch == '-')
                w = -1;
        if (ch == EOF)
            return false;
        while (isdigit(ch))
            s = s * 10 + ch - 48, ch = getchar();
        if (ch == '.')
        {
            ll flt = 0;
            int cnt = 0;
            while (ch = getchar(), isdigit(ch))
                if (cnt < 18)
                    flt = flt * 10 + ch - 48, cnt++;
            s += (db)flt / pow10[cnt];
        }
        return s *= w, true;
    }
    inline bool read(char &s)
    {
        while (s = getchar(), isspace(s))
            ;
        return s != EOF;
    }
    inline bool read(char *s)
    {
        char ch;
        while (ch = getchar(), isspace(ch))
            ;
        if (ch == EOF)
            return false;
        while (!isspace(ch))
            *s++ = ch, ch = getchar();
        *s = '\000';
        return true;
    }
    template <typename T>
    void print(T x)
    {
        static int t[20];
        int top = 0;
        if (x < 0)
            putchar('-'), x = -x;
        do
        {
            t[++top] = x % 10;
            x /= 10;
        } while (x);
        while (top)
            putchar(t[top--] + 48);
    }
    struct empty_type
    {
    };
    int pcs = 8;
    empty_type setpcs(int cnt)
    {
        return pcs = cnt, empty_type();
    }
    inline void print(empty_type x) {}
    inline void print(double x)
    {
        if (x < 0)
            putchar('-'), x = -x;
        x += 5.0 / pow10[pcs + 1];
        print((ll)(x));
        x -= (ll)(x);
        if (pcs != 0)
            putchar('.');
        for (int i = 1; i <= pcs; i++)
            x *= 10, putchar((int)x + '0'), x -= (int)x;
    }
    inline void print(float x)
    {
        if (x < 0)
            putchar('-'), x = -x;
        x += 5.0 / pow10[pcs + 1];
        print((ll)(x));
        x -= (ll)(x);
        if (pcs != 0)
            putchar('.');
        for (int i = 1; i <= pcs; i++)
            x *= 10, putchar((int)x + '0'), x -= (int)x;
    }
    inline void print(char x)
    {
        putchar(x);
    }
    inline void print(char *x)
    {
        for (int i = 0; x[i]; i++)
            putchar(x[i]);
    }
    inline void print(const char *x)
    {
        for (int i = 0; x[i]; i++)
            putchar(x[i]);
    }

// support for string
#ifdef _GLIBCXX_STRING
    inline bool read(std::string &s)
    {
        s = "";
        char ch;
        while (ch = getchar(), isspace(ch))
            ;
        if (ch == EOF)
            return false;
        while (!isspace(ch))
            s += ch, ch = getchar();
        return true;
    }
    inline void print(std::string x)
    {
        for (string::iterator i = x.begin(); i != x.end(); i++)
            putchar(*i);
    }
    inline bool getline(Octane_t &io, string s)
    {
        s = "";
        char ch = getchar();
        if (ch == EOF)
            return false;
        while (ch != '\n' and ch != EOF)
            s += ch, ch = getchar();
        return true;
    }
#endif

// support for initializer_list
#if __cplusplus >= 201103L
    template <typename T, typename... T1>
    inline int read(T &a, T1 &...other)
    {
        return read(a) + read(other...);
    }
    template <typename T, typename... T1>
    inline void print(T a, T1... other)
    {
        print(a);
        print(other...);
    }
#endif

    //  give up iostream
    template <typename T>
    Octane_t &operator>>(Octane_t &io, T &b)
    {
        return io.flag = read(b), io;
    }
    Octane_t &operator>>(Octane_t &io, char *b)
    {
        return io.flag = read(b), io;
    }
    template <typename T>
    Octane_t &operator<<(Octane_t &io, T b)
    {
        return print(b), io;
    }

#define cout io
#define cin io
#define endl '\n'
#undef ll
#undef db
#undef ldb
#undef BUFFER_SIZE
}
using namespace Octane;
#define file(x) freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout)
// #define int long long
const int N = 1e5 + 10;
int L, q;
int p[N];
map<int, pair<int, int>> mp;
signed main()
{
    // file();
    memset(p, 0x3f3f3f, sizeof(p));
    cin >> L >> q;
    for (int i = -L; i <= L; ++i)
        for (int j = i; j <= L; ++j)
            mp[i * i * i + j * j * j] = {i, j};
    for (int i = -L; i <= L; ++i)
        for (int num = 1; num <= 10000; ++num)
        {
            if (abs(p[num]) <= L)
                continue;
            if (mp.count(num - (i * i * i)))
                p[num] = i;
        }
    for (int i = 1, x; i <= q; ++i)
    {
        cin >> x;
        if (abs(p[x]) > L)
            cout << L + 1 << " " << L + 1 << " " << L + 1 << endl;
        else
            cout << p[x] << " " << mp[x - p[x] * p[x] * p[x]].first << " " << mp[x - p[x] * p[x] * p[x]].second << endl;
    }
    cout << endl;
    return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 46ms
memory: 2728kb

input:

98 10
5487
1899
3043
5373
2368
3993
723
9567
6812
901

output:

-46 -10 47
-77 44 72
-36 -29 42
-72 45 66
-12 0 16
-55 44 44
-77 58 64
-28 12 31
-66 27 65
-11 -8 14


result:

ok Correct!


Test #2:

score: 10
Accepted
time: 50ms
memory: 2748kb

input:

99 10
6139
3749
7532
3544
3976
345
522
8442
6400
7965

output:

100 100 100
100 100 100
-12 -1 21
-49 -40 57
-58 42 50
1 1 7
-11 5 12
-84 -47 89
-24 -12 28
-51 2 52


result:

ok Correct!


Test #3:

score: 10
Accepted
time: 50ms
memory: 2728kb

input:

98 10
5078
9597
9394
9368
8777
6955
8020
5115
398
3771

output:

99 99 99
99 99 99
2 5 21
-42 -12 44
-44 -15 46
-60 26 59
-9 -8 21
-14 10 19
-32 15 31
-18 14 19


result:

ok Correct!


Test #4:

score: 10
Accepted
time: 46ms
memory: 2712kb

input:

91 10000
163
6364
2583
7101
5320
483
6442
1028
1209
1710
5617
296
7228
1593
4580
5559
9699
2015
6397...

output:

-76 -68 91
-39 -24 43
-7 9 13
-27 -6 30
-84 36 82
-13 -4 14
92 92 92
-60 37 55
-11 7 13
-52 -35 57
-...

result:

ok Correct!


Test #5:

score: 10
Accepted
time: 50ms
memory: 2708kb

input:

91 10000
6480
8776
1711
1745
4845
3338
343
3167
8450
2756
2252
4375
4912
9822
8053
1533
1216
4161
61...

output:

-84 -39 87
-77 61 62
-54 -33 58
-27 21 23
-20 13 22
-19 13 20
-91 7 91
-20 -10 23
-37 -6 39
6 7 13
9...

result:

ok Correct!


Test #6:

score: 10
Accepted
time: 52ms
memory: 2804kb

input:

95 10000
91
6885
8279
384
5310
2877
4483
2176
267
393
5446
7415
3853
4223
8480
3368
6752
9898
5779
7...

output:

-5 0 6
-86 68 69
-58 -36 63
-52 -46 62
-11 12 17
2 5 14
-48 -26 51
-24 20 20
-10 -4 11
96 96 96
-42 ...

result:

ok Correct!


Test #7:

score: 10
Accepted
time: 1431ms
memory: 113836kb

input:

952 10000
2160
9764
2079
4616
9459
4653
4400
6373
2089
7189
4202
4497
6684
119
1191
2206
9287
5365
1...

output:

-102 80 82
-666 347 633
-631 -357 667
-748 -460 802
-24 11 28
-88 -35 90
-30 24 26
-234 -150 253
-44...

result:

ok Correct!


Test #8:

score: 10
Accepted
time: 2146ms
memory: 123472kb

input:

992 10000
2576
3876
8352
3311
9101
5255
5420
145
7396
6040
8529
9794
5164
4302
7147
3683
152
1136
79...

output:

-302 226 252
-190 119 173
-874 -437 909
-855 -481 903
-488 -212 501
-821 329 803
-42 1 43
-8 -7 10
-...

result:

ok Correct!


Test #9:

score: 10
Accepted
time: 1539ms
memory: 124456kb

input:

996 10000
2189
8757
4831
6765
991
2216
9313
7968
7020
9945
988
9422
7315
2132
2333
5962
1798
8184
22...

output:

-2 0 13
-300 -64 301
-97 32 96
-31 23 29
-872 671 712
-638 -170 642
-447 242 422
-20 7 25
-663 -365 ...

result:

ok Correct!


Test #10:

score: 10
Accepted
time: 1785ms
memory: 122488kb

input:

988 10000
1785
1065
1261
3054
2475
693
9109
9404
1153
4364
1847
8539
4364
9471
6183
6855
303
306
635...

output:

-23 -20 28
-200 121 184
-439 -377 517
-833 274 823
-197 122 180
-742 397 702
-292 154 277
-41 -19 44...

result:

ok Correct!


Extra Test:

score: 0
Extra Test Passed