QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#846640#7115. Can You Guess My Sequence?thanhsAC ✓0ms3792kbC++231.4kb2025-01-07 11:19:502025-01-07 11:19:50

Judging History

你现在查看的是最新测评结果

  • [2025-01-07 11:19:50]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3792kb
  • [2025-01-07 11:19:50]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define name "TENBAI"
#define fi first
#define se second
#define int unsigned long long
#define endl '\n'
#define setmin(x, y) x = min((x), (y))
#define setmax(x, y) x = max((x), (y))
#define sqr(x) ((x) * (x))

mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count());
int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);}

const int NM = 2e3 + 5;


void solve()
{
    string s;
    cin >> s;
    if (s == "Alice")
    {
        int n, t = 0;
        cin >> n;
        for (int i = 1; i <= n; i++)
        {
            int x;
            cin >> x;
            t |= (1 << x);
        }
        cout << t;
    }
    else
    {
        int t;
        cin >> t;
        cout << __builtin_popcount(t) << endl;
        while (t)
        {
            cout << __lg(t & -t) << ' ';
            t ^= (t & -t);
        }
    }
}

signed main()
{
    if (fopen("in.txt", "r")) 
    {
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    }
    else if (fopen(name".inp", "r"))
    {
        freopen(name".inp", "r", stdin);
        freopen(name".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int tc = 1; 
    // cin >> tc;
    while (tc--)
        solve();
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3792kb

First Run Input

Alice
6
2 3 5 8 10 15

First Run Output

34092

Second Run Input

Bob
34092

Second Run Output

6
2 3 5 8 10 15 

result:

ok correct

Test #2:

score: 100
Accepted
time: 0ms
memory: 3616kb

First Run Input

Alice
20
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

First Run Output

1048575

Second Run Input

Bob
1048575

Second Run Output

20
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 

result:

ok correct

Test #3:

score: 100
Accepted
time: 0ms
memory: 3792kb

First Run Input

Alice
1
0

First Run Output

1

Second Run Input

Bob
1

Second Run Output

1
0 

result:

ok correct

Test #4:

score: 100
Accepted
time: 0ms
memory: 3600kb

First Run Input

Alice
2
0 15

First Run Output

32769

Second Run Input

Bob
32769

Second Run Output

2
0 15 

result:

ok correct

Test #5:

score: 100
Accepted
time: 0ms
memory: 3792kb

First Run Input

Alice
10
1 3 5 7 9 11 12 14 15 16

First Run Output

121514

Second Run Input

Bob
121514

Second Run Output

10
1 3 5 7 9 11 12 14 15 16 

result:

ok correct

Test #6:

score: 100
Accepted
time: 0ms
memory: 3784kb

First Run Input

Alice
3
16 17 18

First Run Output

458752

Second Run Input

Bob
458752

Second Run Output

3
16 17 18 

result:

ok correct

Test #7:

score: 100
Accepted
time: 0ms
memory: 3596kb

First Run Input

Alice
18
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 19

First Run Output

655359

Second Run Input

Bob
655359

Second Run Output

18
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 19 

result:

ok correct