ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#215348 | #2777. 2048 | ThySecret | 30 | 893ms | 1144kb | C++11 | 2.9kb | 2024-11-28 20:19:44 | 2024-11-28 23:11:43 |
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];
que[++ tt] = a[k];
// while (hh < tt)
// if (que[hh] == que[hh + 1]) que[++ hh] <<= 1;
// else break;
}
else
{
// if (hh <= tt && que[hh] == a[k])
// que[hh] <<= 1;
// else que[-- hh] = a[k];
que[-- hh] = a[k];
// while (hh < tt)
// if (que[tt] == que[tt - 1]) que[-- tt] <<= 1;
// else break;
}
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;
}
// 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 <= 30) pts20::solve();
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 30
Accepted
Test #1:
score: 30
Accepted
time: 108ms
memory: 1144kb
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: 107ms
memory: 1144kb
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: 111ms
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: 0
Accepted
time: 0ms
memory: 1132kb
input:
20 1 1 2 2 2 8 16 64 32 128 512 128 128 512 512 1024 1024 2048 1024 1024
output:
lllllllrllrlllllllll
result:
ok ok
Test #5:
score: 0
Accepted
time: 110ms
memory: 1144kb
input:
20 2 4 4 4 2 32 128 8 32 32 128 256 256 256 512 8 128 256 2048 4096
output:
no
result:
ok ok
Test #6:
score: 0
Accepted
time: 114ms
memory: 1140kb
input:
20 1 1 2 1 1 1 1 16 32 128 512 8 64 256 1024 1024 2048 2048 512 512
output:
no
result:
ok ok
Test #7:
score: 0
Accepted
time: 112ms
memory: 1140kb
input:
20 4 4 2 2 8 4 4 4 32 256 128 128 256 32 32 512 512 2048 128 4096
output:
no
result:
ok ok
Test #8:
score: 0
Accepted
time: 123ms
memory: 1144kb
input:
20 8 16 16 16 16 16 2 16 512 4 16 2 64 64 2048 128 128 4096 512 512
output:
no
result:
ok ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 1128kb
input:
20 1 1 4 8 2 128 128 16 512 32 64 128 512 512 2048 512 256 256 1024 2048
output:
llrrlrrlrlllllllllll
result:
ok ok
Test #10:
score: 0
Accepted
time: 108ms
memory: 1144kb
input:
20 2 1 1 2 32 64 128 128 128 2 512 512 256 256 2048 2048 8 1024 1024 16
output:
no
result:
ok ok
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 0ms
memory: 1128kb
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