QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#811821#9783. Duloc NetworkI_Love_Sonechka#TL 431ms3812kbC++202.4kb2024-12-13 02:53:392024-12-13 02:53:40

Judging History

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

  • [2024-12-13 02:53:40]
  • 评测
  • 测评结果:TL
  • 用时:431ms
  • 内存:3812kb
  • [2024-12-13 02:53:39]
  • 提交

answer

#include <complex.h>
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pi pair<int, int>
#define pb push_back

using namespace std;
using ll = long long;

template<typename T_container, typename T = typename enable_if
    <!is_same<T_container, string>::value, typename
    T_container::value_type>::type>

ostream& operator<<(ostream &os, const T_container &v) {
    os << '{';
    string sep;
    for(const T &x : v) {
        os << sep << x;
        sep = ", ";
    }
    return os << '}';
}


void dbg_out(){cerr<<endl;}
template <typename Head, typename... Tail>void dbg_out(Head H
    , Tail... T){cerr << ' ' << H; dbg_out(T...); }

#define dbg(...) dbg_out(__VA_ARGS__)

// #define TEST_CASES
#define vt vector

const int amax = 12;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void get() {
    int n = 200;
    double res = 0;
    for(int i = 1; i < n; ++i) {
        double P = 1;
        for(int j = 1; j <= i; ++j) {
            P /= i;
            res += P * j;
            P *= (i-1);
        }
    }
    cout << 2 * res << '\n';
}

void solve() {
    int n; cin >> n;
    map<string, int> queries;
    auto Ask = [&](string s) -> int {
        if(queries.count(s)) {
            return queries[s];
        }
        cout << "? " << s << endl;
        int ret; cin >> ret;
        return queries[s] = ret;
    };
    string S;
    for(int i = 0; i < n; ++i) {
        S.push_back('0');
    }
    S[rng() % n] = '1';
    for(int i = 1; i < n; ++i) {
        vt<int> other;
        for(int j = 0; j < n; ++j) if(S[j] == '0') {
            other.push_back(j);
        }
        int value = Ask(S);
        if(value == n - i) {
            break;
        }
        if(value == 0) {
            cout << "! 0" << endl;
            return ;
        }
        shuffle(other.begin(), other.end(), rng);
        for(auto u: other) {
            string T = S;
            T[u] = '1';
            for(auto &c: T) {
                c = (1 - (c-'0')) + '0';
            }
            if(Ask(T) <= value) {
                S[u] = '1';
                break;
            }
        }
    }
    cout << "! 1" << endl;
}

int main() {
    // cin.tie(0)->sync_with_stdio(0);
int tt = 1e6;
#ifdef TEST_CASES
    cin >> tt;
#endif
    while(tt--)
        solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 172ms
memory: 3812kb

input:

4
3

output:

? 0100
! 1

result:

ok Correct answer with 1 queries.

Test #2:

score: 0
Accepted
time: 132ms
memory: 3540kb

input:

2
0

output:

? 10
! 0

result:

ok Correct answer with 1 queries.

Test #3:

score: 0
Accepted
time: 431ms
memory: 3608kb

input:

4
1
2
1
2

output:

? 1000
? 0101
? 0011
? 1100
! 1

result:

ok Correct answer with 4 queries.

Test #4:

score: 0
Accepted
time: 142ms
memory: 3540kb

input:

2
0

output:

? 10
! 0

result:

ok Correct answer with 1 queries.

Test #5:

score: -100
Time Limit Exceeded

input:

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

output:

? 00000000100000000000000000000000000000000000000000
? 11111111011111111111111111111111111111111011111111
? 11111111011111111111111111111111111111111101111111
? 11111111011111111111111111111111111111111111111011
? 11111111011111111111111111111111011111111111111111
? 111111110111111111111011111111111...

result: