UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#215347#2777. 2048ThySecret0318ms1144kbC++112.2kb2024-11-28 20:15:012024-11-28 23:11:39

answer

#include <bits/stdc++.h>

using namespace std;

// #define int long long
// #define x first
// #define y second
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)

inline void debug() { cerr << '\n'; }
template<typename Type, typename... Other>
inline void debug(const Type& x, const Other&... y) { cerr << x << ' '; debug(y...); }
#define DEBUG(a...) cerr << "[" << #a << "] = ", debug(a);

typedef long long LL;
typedef pair<int, int> PII;

const int N = 200010;
const int INF = 0x3f3f3f3f;

template<typename Type>
inline void read(Type &res)
{
    res = 0;
    int ch = getchar(), flag = 0;
    while (!isdigit(ch)) flag |= ch == '-', ch = getchar();
    while (isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
    res = flag ? -res : res;
}
template<typename Type, typename... Other>
inline void read(Type &res, Other&... y) { read(res), read(y...); }

int n, a[N];

namespace pts20
{
    int que[N], hh = 50, tt = 49;

    void solve()
    {
        for (int state = 0; state < 1 << n; state ++)
        {
            hh = 50, tt = 49;
            for (int k = 1; k <= n; k ++)
            {
                if (state >> (k - 1) & 1)
                {
                    if (hh <= tt && que[tt] == a[k])
                        que[tt] <<= 1;
                    else que[++ tt] = a[k];
                }
                else
                {
                    if (hh <= tt && que[hh] == a[k])
                        que[hh] <<= 1;
                    else que[-- hh] = a[k];
                }
            }
            while (hh < tt)
                if (que[hh] == que[hh + 1]) que[++ hh] <<= 1;
                else break;
            while (hh < tt)
                if (que[tt] == que[tt - 1]) que[-- tt] <<= 1;
                else break;

            if (hh == tt)
            {
                for (int k = 0; k < n; k ++)
                    if (state >> k & 1) putchar('r');
                    else putchar('l');
                putchar(10);
                return;
            }
        }
        printf("no\n");
    }
}

signed main()
{
    read(n);
    for (int i = 1; i <= n; i ++) read(a[i]);
    if (n <= 20) pts20::solve();
    return 0;
}

详细

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

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 30
Accepted
time: 80ms
memory: 1140kb

input:

20
2 8 8 256 2 32 64 64 2 2 64 8 256 128 128 1024 2048 2048 1024 1024

output:

no

result:

ok ok

Test #2:

score: 0
Accepted
time: 79ms
memory: 1140kb

input:

20
1 1 2 4 8 8 8 1024 32 32 16 16 128 1024 1024 128 64 64 4096 512

output:

no

result:

ok ok

Test #3:

score: 0
Accepted
time: 79ms
memory: 1140kb

input:

20
1 2 1 8 4 64 64 4 4 8 2048 32 4096 128 128 64 512 512 256 256

output:

no

result:

ok ok

Test #4:

score: -30
Wrong Answer
time: 80ms
memory: 1144kb

input:

20
1 1 2 2 2 8 16 64 32 128 512 128 128 512 512 1024 1024 2048 1024 1024

output:

no

result:

wrong answer participant output is not correct

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 0ms
memory: 1124kb

input:

50
1 1 2 2 8 8 8 8 1 1 16 8 8 4 4 8 8 8 64 32 8 8 16 256 256 64 64 128 4 4 256 128 128 256 256 1024 ...

output:


result:

wrong answer participant output is not valid

Subtask #3:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 0ms
memory: 1132kb

input:

1000
1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 2 1 1 1 1 8 8 16 1 1 1 1 1 1 1 1 16 8 1 1 1 1 1 1 2 8 8 4 4 4 4...

output:


result:

wrong answer participant output is not valid