QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#628100#7184. Transport Plusesucup-team3519#RE 0ms0kbC++173.3kb2024-10-10 18:34:362024-10-10 18:34:36

Judging History

This is the latest submission verdict.

  • [2024-10-10 18:34:36]
  • Judged
  • Verdict: RE
  • Time: 0ms
  • Memory: 0kb
  • [2024-10-10 18:34:36]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define V vector
#define pb push_back
typedef double db;
typedef long long LL;

typedef pair<int, int> pi;
#define fi first
#define se second
#define all0(x) (x).begin(), (x).end()

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

string get_c(char c) {
    string s;
    int val = c - 'A';
    for(int i = 4; i >= 0; i--) {
        s.pb((val >> i & 1) + '0'); 
    }
    return s;
}

int get_i(string s) {
    int ans = 0;
    for(int i = 4; i >= 0; i--) {
        ans += (1 << i) * (s[4 - i] - '0');
    }
    // cout << s << " " << ans << endl;
    return ans;
}

void prepare() {
    string s; cin >> s;
    string say;
    for(int i = 0; i < 10; i++) {
        say += get_c(s[i]);
    }
    cout << say << endl;
}

void play() {

    auto match_two = [&](int a, int b) -> bool {
        a++, b++;
        cout << a << endl;
        string s; cin >> s;
        cout << b << endl;
        cin >> s;
        assert(s[1] == '+' || s[1] == '!');
        if(s[1] == '!') return 1;
        return 0;
    };

    auto check1 = [&](int a) -> int {
        a++;
        cout << a << endl;
        string s; cin >> s;
        return s[0] - 'A';
    };

    auto check2 = [&](int a) -> int {
        a++;
        cout << a << endl;
        string s; cin >> s;
        return s[0] - 'A';
    };

    string s; cin >> s;
    V<int> pos(25, -1);
    V<int> a(10);
    // cout << s << endl;
    for(int i = 0; i < 10; i++) {
        a[i] = get_i(s.substr(i * 5, 5));
        if(pos[a[i]] != -1) {
            match_two(pos[a[i]], i);
        }
        pos[a[i]] = i;
    }

    int now = 10;

    while(now != 50) {
        int a = check1(now);
        if(pos[a] != -1) {
            // cout << "hav a" << endl;
            check2(pos[a]);
            now++;
            continue;
        }
        else pos[a] = now;

        // cout << "check2" << endl;

        now++;
        int b = check2(now);
        if(pos[b] != -1 && a != b) {
            match_two(pos[b], now);
        } else pos[b] = now;
        now++;
    }
}




int main() {
    // cout << fixed << setprecision(10);
    // auto play = [&](string s) -> int {
    //     int now = 0;
    //     int cost = 0;
    //     V<int> hav(25);
    //     for(int i = 0; i < 10; i++) hav[s[i] - 'A'] = 1;
    //     while(now != 50) {
    //         if(hav[s[now] - 'A']) {
    //             now++;
    //             continue;
    //         }
    //         if(s[now] != s[now + 1]) {
    //             cost++;
    //             hav[s[now] - 'A'] = 1, hav[s[now + 1] - 'A'] = 1;
    //         }
    //         now += 2;
    //     }
    //     return cost;
    // };

    // db cnt = 0;
    // auto gen = [&]() -> string {
    //     string s;
    //     for(int i = 'A'; i <= 'Y'; i++) {
    //         s.pb(i);
    //         s.pb(i);
    //     }
    //     shuffle(all0(s), mrand);
    //     return s;
    // };

    // for(int i = 1; i <= 100; i++) {
    //     cnt += play(gen());
    // }
    // cnt /= 100;

    // cout << cnt << endl;

    string type; cin >> type;
    if(type == "prepare") {
        int t; cin >> t;
        while(t--)
        prepare();
    } else {
        int t; cin >> t;
        while(t--)
        play();
    }
}   

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

1 2
1 1
5 3
6 2

output:

1
1

result: