QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#827922#9783. Duloc NetworkZawosWA 3ms3824kbC++201.5kb2024-12-23 11:29:392024-12-23 11:29:40

Judging History

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

  • [2024-12-23 11:29:40]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3824kb
  • [2024-12-23 11:29:39]
  • 提交

answer

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

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)

int ask(set<int> st, int n) {
    string s(n, '0');
    for (auto x : st)
        s[x] = '1';
    cout << "? " << s << endl;
    int res; cin >> res;
    return res;
}

set<int> OR(set<int> &a, set<int> &b) {
    set<int> st = a;
    for (auto x : b)    
        st.insert(x);
    return st;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    set<int> A, B;
    A.insert(0);
    rep(i, 1, n)
        B.insert(i);
    int fA = ask(A, n);
    rep(i, 0, n - 1) {
        if (!fA) return cout << "! 0" << endl, 0;
        set<int> cur = B;

        while (cur.size() > 1) {
            set<int> L;
            while (L.size() < cur.size()) {
                L.insert(*cur.begin());
                cur.erase(cur.begin());
            }

            int fB = ask(L, n), fAB = fA + ask(OR(A, L), n);
            if (!fB) return cout << "! 0" << endl, 0; 
            if (fA + fB != fAB)
                cur = L;
        }

        if (cur.empty() || fA + ask(cur, n) == fA + ask(OR(A, cur), n)) cout << "! 0" << endl, 0; 

        A.insert(*cur.begin());
        B.erase(*cur.begin());
        fA = ask(A, n);
    }

    cout << "! 1" << endl;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3552kb

input:

4
1
2
1
3
2
3
2
2
2
1
2
1
1
2
0
0

output:

? 1000
? 0110
? 1110
? 0100
? 1100
? 0100
? 1100
? 1100
? 0010
? 1110
? 0010
? 1110
? 1110
? 0001
? 1111
? 1111
! 1

result:

ok Correct answer with 16 queries.

Test #2:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

2
0

output:

? 10
! 0

result:

ok Correct answer with 1 queries.

Test #3:

score: 0
Accepted
time: 1ms
memory: 3668kb

input:

4
1
2
1
3
2
3
2
2
2
1
2
1
1
2
0
0

output:

? 1000
? 0110
? 1110
? 0100
? 1100
? 0100
? 1100
? 1100
? 0010
? 1110
? 0010
? 1110
? 1110
? 0001
? 1111
? 1111
! 1

result:

ok Correct answer with 16 queries.

Test #4:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

2
0

output:

? 10
! 0

result:

ok Correct answer with 1 queries.

Test #5:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

50
3
13
14
13
14
9
12
4
7
2
5
1
4
1
4
4
14
14
15
15
9
11
4
8
4
8
4
8
4
8
8
14
14
15
17
12
15
7
13
5
12
3
11
3
11
11
15
14
14
15
10
17
3
12
2
12
1
11
1
11
11
14
13
15
17
10
16
5
15
2
12
1
12
1
12
12
14
13
15
17
11
17
8
16
5
15
1
12
1
12
12
14
12
17
18
10
17
8
17
7
16
4
15
4
15
15
15
12
17
17
6
17
3
1...

output:

? 10000000000000000000000000000000000000000000000000
? 01111111111111111111111111000000000000000000000000
? 11111111111111111111111111000000000000000000000000
? 01111111111111000000000000000000000000000000000000
? 11111111111111000000000000000000000000000000000000
? 011111110000000000000000000000000...

result:

ok Correct answer with 481 queries.

Test #6:

score: 0
Accepted
time: 3ms
memory: 3496kb

input:

50
10
25
24
36
35
33
34
29
30
19
21
13
19
13
19
19
26
24
37
35
31
34
23
30
12
22
8
21
8
21
21
26
23
37
34
32
35
22
32
18
30
6
22
6
22
22
27
23
36
33
30
35
23
33
18
32
13
30
13
30
30
27
22
36
32
32
34
20
34
16
33
8
32
8
32
32
28
22
37
32
36
35
21
35
15
34
10
33
10
33
33
28
21
36
31
36
36
24
33
20
34
...

output:

? 10000000000000000000000000000000000000000000000000
? 01111111111111111111111111000000000000000000000000
? 11111111111111111111111111000000000000000000000000
? 01111111111111000000000000000000000000000000000000
? 11111111111111000000000000000000000000000000000000
? 011111110000000000000000000000000...

result:

ok Correct answer with 610 queries.

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3744kb

input:

50
1
16
16
17
18
13
14
7
8
5
6
4
5
4
5
5
17
18
16
18
13
15
8
10
4
8
3
7
3
7
7
17
17
17
18
13
14
6
13
3
10
1
8
1
8
8
18
17
13
16
9
15
8
14
5
11
1
9
1
9
9
17
16
12
16
7
14
8
15
7
14
4
11
4
11
11
17
16
10
16
6
16
5
16
4
15
3
14
3
14
14
18
16
13
16
7
17
3
15
2
16
1
15
1
15
15
17
16
12
15
7
16
2
14
2
15
...

output:

? 10000000000000000000000000000000000000000000000000
? 01111111111111111111111111000000000000000000000000
? 11111111111111111111111111000000000000000000000000
? 00000000000000000000000000111111111111000000000000
? 10000000000000000000000000111111111111000000000000
? 000000000000000000000000001111110...

result:

wrong answer Wrong answer.