昨晚 CF Div.2 E2 WA on #29 求助
  • 板块学术版
  • 楼主Eason_cyx大愚若智
  • 当前回复0
  • 已保存回复0
  • 发布时间2025/8/1 15:12
  • 上次更新2025/8/1 20:09:34
查看原帖
昨晚 CF Div.2 E2 WA on #29 求助
741244
Eason_cyx大愚若智楼主2025/8/1 15:12

rt,思路跟题解一样。

貌似是 if(n % 8) 的地方锅了(盲猜)

#29 中 n=999n=999,是 Wrong Answer,回答的括号串有误,而不是超出次数限制

求助qwq

#include <bits/stdc++.h>
using namespace std;
int n, res;
void get(int &x, int &y) {
    cout << "? 2 " << n << " 1" << endl;
    cin >> res; 
    if(res) { x = n; y = 1; return ; }
    int l = 1, r = n;
    while(l < (r-1)) {
        int mid = (l + r) >> 1;
        cout << "? 2 " << mid << " " << mid+1 << endl;
        cin >> res;
        if(res > 0) { x = mid; y = mid+1; return ; }
        cout << "? " << mid-l+1 << " ";
        for(int i = l;i <= mid;i++)
            cout << i << " ";
        cout << endl; cin >> res; 
        if(res > 0) r = mid; else l = mid + 1;
    } x = l; y = r; return ;
} int main() {
    int t; cin >> t; 
    while(t--) {
        cin >> n; 
        int x, y; get(x, y);
        if(n < 8) {
            string s;
            for(int i = 1;i < n;i += 2) {
                cout << "? 7 " << x << " " << i << " " << i+1 << " " << i+1 << " " << y << " " << y << " " << y << endl; cout.flush();
                cin >> res;
                if(res == 1) s += "))";
                if(res == 2) s += "()";
                if(res == 3) s += "((";
                if(res == 4) s += ")(";
            } if(n & 1) {
                cout << "? 7 " << x << " " << n-1 << " " << n << " " << n << " " << y << " " << y << " " << y << endl; cout.flush();
                cin >> res; 
                if(res <= 2) s += ")"; else s += "(";
            } cout << "! " << s << endl; continue;
        } string s;
        cout << "? 518 ";
        for(int j = 128;j >= 1;j >>= 1) {
            for(int k = 1;k <= j;k++) cout << x << " " << y << " ";
            cout << y << " ";
        } cout << endl; int res1; cin >> res1;
        for(int i = 1;i + 7 <= n;i += 8) {
            cout << "? 518 ";
            for(int j = 128, k = 7;j >= 1;j >>= 1, k--) {
                cout << i+k << " " << y << " ";
                for(int l = 1;l < j;l++) cout << x << " " << y << " ";
                cout << y << " ";
            } cout << endl; int res2; cin >> res2;
            int rr = res1 - res2;
            for(int j = 0;j < 8;j++)
                if(rr % 2) rr >>= 1, s += ')';
                else rr >>= 1, s += '(';
        } if(n % 8) {
            cout << "? ";
            int sum = 0;
            for(int j = pow(2, n%8), k = n%8;j >= 1;j >>= 1, k--) 
                sum += 2 * j + 1;
            cout << sum << " ";
            for(int j = pow(2, n%8), k = n%8;j >= 1;j >>= 1, k--) {
                cout << n-k << " " << y << " ";
                for(int l = 1;l < j;l++) cout << x << " " << y << " ";
                cout << y << " ";
            } cout << endl; int res2; cin >> res2;
            cout << "? " << sum << endl;
             for(int j = pow(2, n%8), k = n%8;j >= 1;j >>= 1, k--) {
                for(int l = 1;l <= j;l++) cout << x << " " << y << " ";
                cout << y << " ";
            } cout << endl; int res3; cin >> res3;
            int rr = res3 - res2;
            for(int j = 0;j < n%8;j++)
                if(rr % 2) rr >>= 1, s += ")";
                else rr >>= 1, s += '(';
        } cout << "! " << s << endl;
    }
    return 0;
}
2025/8/1 15:12
加载中...